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

# Create Template From Optimization

> Create a project optimization template from an existing optimization.

Copies the optimization's saved config into the new template's
``initial_form_data`` (both follow the same schema), so the client no longer
re-maps the config through the optimization form to save a template.

Parameters
----------
body : FromOptimizationRequest
    The source optimization id plus the new template's name/description.

Returns
-------
OptimizationTemplate
    The created project-level template.

Raises
------
NotFoundError
    If the optimization does not exist.
BadRequestError
    If the name is blank or the optimization has no valid saved
    configuration to turn into a template.
ConflictError
    If a template with the same name already exists in the project.



## OpenAPI

````yaml https://api.ionworks.com/openapi.json post /optimization_templates/from-optimization
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://api.ionworks.com
    description: Production
security: []
paths:
  /optimization_templates/from-optimization:
    post:
      tags:
        - optimization_templates
      summary: Create Template From Optimization
      description: >-
        Create a project optimization template from an existing optimization.


        Copies the optimization's saved config into the new template's

        ``initial_form_data`` (both follow the same schema), so the client no
        longer

        re-maps the config through the optimization form to save a template.


        Parameters

        ----------

        body : FromOptimizationRequest
            The source optimization id plus the new template's name/description.

        Returns

        -------

        OptimizationTemplate
            The created project-level template.

        Raises

        ------

        NotFoundError
            If the optimization does not exist.
        BadRequestError
            If the name is blank or the optimization has no valid saved
            configuration to turn into a template.
        ConflictError
            If a template with the same name already exists in the project.
      operationId: >-
        create_template_from_optimization_optimization_templates_from_optimization_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FromOptimizationRequest'
        required: true
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OptimizationTemplate'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    FromOptimizationRequest:
      properties:
        optimization_id:
          type: string
          title: Optimization Id
        name:
          type: string
          title: Name
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
      type: object
      required:
        - optimization_id
        - name
      title: FromOptimizationRequest
      description: Request body for creating a template from an existing optimization.
    OptimizationTemplate:
      properties:
        name:
          type: string
          title: Name
          description: The name of the optimization template.
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: An optional description for the template.
        initial_form_data:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Initial Form Data
          description: Initial form data values.
        id:
          type: string
          title: Id
          description: The unique identifier for the template.
        organization_id:
          type: string
          title: Organization Id
          description: The ID of the organization this template belongs to.
        project_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Project Id
          description: The ID of the owner project (None for system templates).
        access_level:
          type: string
          title: Access Level
          description: 'Template scope: ''system'' for built-in, ''project'' for user-created.'
          default: project
        created_at:
          type: string
          format: date-time
          title: Created At
          description: Timestamp of when the template was created.
        updated_at:
          type: string
          format: date-time
          title: Updated At
          description: Timestamp of when the template was last updated.
      type: object
      required:
        - name
        - id
        - organization_id
        - created_at
        - updated_at
      title: OptimizationTemplate
      description: Model representing an optimization template as returned by the API.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````