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

# Create a Stream Template

> Save a created stream's configuration as a named template.

## Overview

Saves an existing stream's configuration under a name, so the same setup can
be recreated later without rebuilding the payload. The template stores no
configuration of its own: applying it with
[Use a Stream Template](use-template) replays the referenced stream's
original creation payload.

The `stream_id` must belong to a stream created in your workspace. Template
names are unique per workspace, and each workspace can hold at most 20
templates; a duplicate name or a full workspace returns `409`.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://client.camb.ai/apis/stream/templates/" \
    -H "x-api-key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"name": "matchday-dubbing", "stream_id": 4821}'
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://client.camb.ai/apis/stream/templates/",
      headers={"x-api-key": "YOUR_API_KEY"},
      json={"name": "matchday-dubbing", "stream_id": 4821},
  )

  response.raise_for_status()
  print(response.json())
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "id": 12,
    "name": "matchday-dubbing",
    "stream_id": 4821
  }
  ```
</ResponseExample>

## Related endpoints

* [List Stream Templates](list-templates)
* [Use a Stream Template](use-template)
* [Delete a Stream Template](delete-template)


## OpenAPI

````yaml post /stream/templates/
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://client.camb.ai/apis
security: []
paths:
  /stream/templates/:
    post:
      tags:
        - Apis
        - Streaming
      summary: Create a Stream Template
      description: >-
        Save a created stream's configuration as a named template in your
        workspace. Applying the template later replays that stream's creation
        payload. Template names are unique per workspace, and each workspace can
        hold at most 20 templates.
      operationId: create_stream_template_stream_templates__post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateStreamTemplateRequestPayload'
            example:
              name: matchday-dubbing
              stream_id: 4821
      responses:
        '200':
          description: The created template.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StreamTemplateOut'
        '404':
          description: The stream does not exist in your workspace.
        '409':
          description: >-
            A template with this name already exists, or the workspace has
            reached the 20-template limit.
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    CreateStreamTemplateRequestPayload:
      type: object
      title: CreateStreamTemplateRequestPayload
      required:
        - name
        - stream_id
      properties:
        name:
          type: string
          title: Name
          minLength: 1
          maxLength: 100
          description: The template's name, unique within the workspace.
        stream_id:
          type: integer
          exclusiveMinimum: 0
          title: Stream Id
          description: >-
            The id of a created stream in your workspace whose configuration the
            template saves.
    StreamTemplateOut:
      type: object
      title: StreamTemplateOut
      required:
        - id
        - name
        - stream_id
      properties:
        id:
          type: integer
          title: Id
          description: The template id.
        name:
          type: string
          title: Name
          description: The template's name, unique within the workspace.
        stream_id:
          type: integer
          title: Stream Id
          description: The stream this template was saved from.
    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
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        The `x-api-key` is a custom header required for authenticating requests
        to our API. Include this header in your request with the appropriate API
        key value to securely access our endpoints. You can find your API key(s)
        in the 'API' section of our studio website.

````