# Apply Pipeline Template

`POST /v1/pipelines/templates:apply`

Apply the file as the workspace's template of its ``name``: created
the first time, the next immutable version when its graph or outputs
changed, its description updated in place when only that changed, and
``changed: false`` when nothing did. Safe to retry.

- Base URL: `https://junction-api.qualiastudios.dev`
- Authentication: an API key in the `X-API-Key` header, or `Authorization: Bearer …`

## Request body

Required: `application/json` `TemplateSource`

## Responses

- `200` Successful Response: `application/json` `AppliedTemplate`
- `401` Invalid or missing API key: `application/json` `ErrorResponse`
- `403` Missing capability on the workspace: `application/json` `ErrorResponse`
- `409` The template is retired: `application/json` `ErrorResponse`
- `422` The file is not a valid template

## Schemas

```yaml
TemplateSource:
  properties:
    source:
      type: string
      maxLength: 65536
      description: "The TOML file: name, description, nodes, edges, outputs"
  additionalProperties: false
  type: object
  required:
    - source
  title: TemplateSource
  description: A template file, as it is kept in the workspace's repository.
AppliedTemplate:
  properties:
    pipeline_template_id:
      type: string
      format: uuid
    name:
      type: string
    version:
      type: integer
    changed:
      type: boolean
      description: False when nothing was written; a new graph or outputs is a new version, a new description is written in place
    launch_fields:
      items:
        $ref: "#/components/schemas/LaunchField"
      type: array
  type: object
  required:
    - pipeline_template_id
    - name
    - version
    - changed
  title: AppliedTemplate
LaunchField:
  properties:
    name:
      type: string
    type_name:
      type: string
    schema:
      additionalProperties: true
      type: object
    required:
      type: boolean
    default:
      nullable: true
    resolve:
      nullable: true
      additionalProperties: true
      type: object
    ui:
      additionalProperties: true
      type: object
  type: object
  required:
    - name
    - type_name
    - required
  title: LaunchField
  description: |-
    One launch-form field of a template: an exposed port with its JSON
    schema, derived required-ness, and display metadata.
ErrorResponse:
  properties:
    detail:
      type: string
      description: Error message describing what went wrong
  type: object
  required:
    - detail
  title: ErrorResponse
  description: Standard error response.
```
