---
title: "Create an Extension"
method: POST
path: "/extensions"
tags: ["Extensions"]
---

# Create an Extension

`POST /extensions`

Create a new Extension in a provided project

## Request body

- Extension
  - `archived` boolean — Whether the extension is archived
  - `created` string, date-time — The time when the extension was initially created
  - `description` string — The description for the extension
  - `edit_url` string, required — The URL to load when editing the extension
  - `enabled` boolean — Whether the extension is enabled. A disabled extension won't appear in the editor and won't be built into the snippet
  - `experiment_count` integer — Number of experiments that reference this extension across all statuses (running, paused, draft, archived). Computed by the upstream service.
  - `fields` Field[] — Array of editable fields in the extension
    - `api_name` string, required — The API name of the field
    - `default_value` string, required — A string in JSON format that corresponds to the default_value of the field
    - `field_type` 'selector' | 'text' | 'multi_text' | 'rich_text' | 'number' | 'html' | 'css' | 'js' | 'toggle' | 'dropdown' | 'multi_select' | 'image' | 'color' | 'slider', required — The type of the field
    - `label` string, required — The label of the field
    - `options` Options
      - `choices` Choices[] — The choices for a field
        - `label` string — label of the choice
        - `value` string — value of the choice
  - `id` integer — The unique identifier for the extension
  - `implementation` Implementation, required
    - `apply_js` string — The Apply JS code is used to inject the extension onto the page
    - `css` string — Some extensions may not need any CSS because they inherit styles from the page itself. However, you can add additional styling here. This will be injected on the page through a <style> tag
    - `html` string — The html implementation of the field
    - `reset_js` string — Reset JS is used to "clean up" after a extension. It's used in the editor, when changing field values or removing an existing extension. Reset JS should remove the element and any other side-effects
  - `last_modified` string, date-time — The last time when the extension was modified
  - `name` string, required — Name of the extension
  - `project_id` integer, required — The project the extension is in

## Response `201`

Return the created extension

- Extension
  - `archived` boolean — Whether the extension is archived
  - `created` string, date-time — The time when the extension was initially created
  - `description` string — The description for the extension
  - `edit_url` string, required — The URL to load when editing the extension
  - `enabled` boolean — Whether the extension is enabled. A disabled extension won't appear in the editor and won't be built into the snippet
  - `experiment_count` integer — Number of experiments that reference this extension across all statuses (running, paused, draft, archived). Computed by the upstream service.
  - `fields` Field[] — Array of editable fields in the extension
    - `api_name` string, required — The API name of the field
    - `default_value` string, required — A string in JSON format that corresponds to the default_value of the field
    - `field_type` 'selector' | 'text' | 'multi_text' | 'rich_text' | 'number' | 'html' | 'css' | 'js' | 'toggle' | 'dropdown' | 'multi_select' | 'image' | 'color' | 'slider', required — The type of the field
    - `label` string, required — The label of the field
    - `options` Options
      - `choices` Choices[] — The choices for a field
        - `label` string — label of the choice
        - `value` string — value of the choice
  - `id` integer — The unique identifier for the extension
  - `implementation` Implementation, required
    - `apply_js` string — The Apply JS code is used to inject the extension onto the page
    - `css` string — Some extensions may not need any CSS because they inherit styles from the page itself. However, you can add additional styling here. This will be injected on the page through a <style> tag
    - `html` string — The html implementation of the field
    - `reset_js` string — Reset JS is used to "clean up" after a extension. It's used in the editor, when changing field values or removing an existing extension. Reset JS should remove the element and any other side-effects
  - `last_modified` string, date-time — The last time when the extension was modified
  - `name` string, required — Name of the extension
  - `project_id` integer, required — The project the extension is in

## Other responses

- `400` — Invalid request body content
- `401` — Invalid credentials
- `403` — You do not have permission to create an extension under the specified project
- `default` — Unexpected error

---

[API](https://skmtc.dev/optimizely/apis/optimizely-api.md) · [All operations](https://skmtc.dev/optimizely/apis/optimizely-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/optimizely/optimizely-api/revisions/5151fe6a2297/schema)
