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

# Create Link Template

> Create a reusable link template



## OpenAPI

````yaml openapi.json POST /api/workspaces/{workspace_id}/link-templates
openapi: 3.1.1
info:
  title: Middlewr API
  description: Short link management platform API
  version: 1.0.0
  contact:
    name: Middlewr
    email: hello@middlewr.com
    url: https://middlewr.com/contact
servers:
  - url: https://api.middlewr.com
security:
  - ApiKeyAuth: []
paths:
  /api/workspaces/{workspace_id}/link-templates:
    post:
      tags:
        - Link Templates
      operationId: linkTemplates.create
      parameters:
        - name: workspace_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                title:
                  type: string
                  minLength: 1
                  maxLength: 255
                description:
                  type: string
                  maxLength: 2000
                rule_graph:
                  anyOf:
                    - $ref: '#/components/schemas/RuleGraphInput'
                    - type: 'null'
              required:
                - title
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LinkTemplate'
components:
  schemas:
    RuleGraphInput:
      type: object
      properties:
        entry:
          type: string
        nodes:
          type: object
          propertyNames:
            type: string
          additionalProperties:
            anyOf:
              - type: object
                properties:
                  id:
                    type: string
                  type:
                    const: condition
                  position:
                    type: object
                    properties:
                      x:
                        type: number
                      'y':
                        type: number
                    required:
                      - x
                      - 'y'
                  field:
                    type: string
                  operator:
                    enum:
                      - eq
                      - neq
                      - in
                      - not_in
                      - contains
                      - not_contains
                      - gt
                      - lt
                      - gte
                      - lte
                      - regex
                    type: string
                  value:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                      - type: number
                  outputs:
                    type: object
                    properties:
                      'true':
                        anyOf:
                          - type: string
                          - type: 'null'
                      'false':
                        anyOf:
                          - type: string
                          - type: 'null'
                    required:
                      - 'true'
                      - 'false'
                required:
                  - id
                  - type
                  - position
                  - field
                  - operator
                  - value
                  - outputs
              - type: object
                properties:
                  id:
                    type: string
                  type:
                    const: split
                  position:
                    type: object
                    properties:
                      x:
                        type: number
                      'y':
                        type: number
                    required:
                      - x
                      - 'y'
                  variants:
                    type: array
                    minItems: 2
                    items:
                      type: object
                      properties:
                        weight:
                          type: number
                          minimum: 1
                          maximum: 100
                        target:
                          anyOf:
                            - type: string
                            - type: 'null'
                      required:
                        - weight
                        - target
                required:
                  - id
                  - type
                  - position
                  - variants
              - type: object
                properties:
                  id:
                    type: string
                  type:
                    const: destination
                  position:
                    type: object
                    properties:
                      x:
                        type: number
                      'y':
                        type: number
                    required:
                      - x
                      - 'y'
                  url:
                    type: string
                    format: uri
                required:
                  - id
                  - type
                  - position
                  - url
              - type: object
                properties:
                  id:
                    type: string
                  type:
                    const: transform
                  position:
                    type: object
                    properties:
                      x:
                        type: number
                      'y':
                        type: number
                    required:
                      - x
                      - 'y'
                  transforms:
                    type: object
                    properties:
                      query_params:
                        type: array
                        items:
                          type: object
                          properties:
                            key:
                              type: string
                              minLength: 1
                            value:
                              type: string
                            mode:
                              enum:
                                - set
                                - append
                              type: string
                          required:
                            - key
                            - value
                            - mode
                      redirect_status:
                        anyOf:
                          - const: 301
                          - const: 302
                          - const: 307
                          - const: 308
                      response_headers:
                        type: array
                        items:
                          type: object
                          properties:
                            key:
                              type: string
                              minLength: 1
                            value:
                              type: string
                              pattern: ^[^\r\n]*$
                            mode:
                              enum:
                                - set
                                - append
                              type: string
                          required:
                            - key
                            - value
                            - mode
                  next:
                    anyOf:
                      - type: string
                      - type: 'null'
                required:
                  - id
                  - type
                  - position
                  - transforms
                  - next
              - type: object
                properties:
                  id:
                    type: string
                  type:
                    const: password
                  position:
                    type: object
                    properties:
                      x:
                        type: number
                      'y':
                        type: number
                    required:
                      - x
                      - 'y'
                  next:
                    anyOf:
                      - type: string
                      - type: 'null'
                required:
                  - id
                  - type
                  - position
                  - next
              - type: object
                properties:
                  id:
                    type: string
                  type:
                    const: countdown
                  position:
                    type: object
                    properties:
                      x:
                        type: number
                      'y':
                        type: number
                    required:
                      - x
                      - 'y'
                  seconds:
                    type: integer
                    minimum: 1
                    maximum: 300
                  message:
                    anyOf:
                      - type: string
                        maxLength: 500
                      - type: 'null'
                  next:
                    anyOf:
                      - type: string
                      - type: 'null'
                required:
                  - id
                  - type
                  - position
                  - seconds
                  - message
                  - next
              - type: object
                properties:
                  id:
                    type: string
                  type:
                    const: webhook
                  position:
                    type: object
                    properties:
                      x:
                        type: number
                      'y':
                        type: number
                    required:
                      - x
                      - 'y'
                  url:
                    type: string
                    format: uri
                  method:
                    enum:
                      - POST
                      - GET
                    type: string
                  headers:
                    type: object
                    propertyNames:
                      type: string
                    additionalProperties:
                      type: string
                      pattern: ^[^\r\n]*$
                  next:
                    anyOf:
                      - type: string
                      - type: 'null'
                required:
                  - id
                  - type
                  - position
                  - url
                  - method
                  - next
              - type: object
                properties:
                  id:
                    type: string
                  type:
                    const: entry
                  position:
                    type: object
                    properties:
                      x:
                        type: number
                      'y':
                        type: number
                    required:
                      - x
                      - 'y'
                  next:
                    anyOf:
                      - type: string
                      - type: 'null'
                  starts_at:
                    anyOf:
                      - type: string
                        format: date-time
                      - type: 'null'
                  expires_at:
                    anyOf:
                      - type: string
                        format: date-time
                      - type: 'null'
                  fallback_url:
                    anyOf:
                      - type: string
                      - type: 'null'
                required:
                  - id
                  - type
                  - position
                  - next
                  - starts_at
                  - expires_at
                  - fallback_url
      required:
        - entry
        - nodes
    LinkTemplate:
      type: object
      properties:
        id:
          type: string
          format: uuid
        workspace_id:
          type: string
          format: uuid
        title:
          type: string
        description:
          anyOf:
            - type: string
            - type: 'null'
        rule_graph:
          anyOf:
            - $ref: '#/components/schemas/RuleGraph'
            - type: 'null'
        created_at:
          type: string
          format: date-time
          x-native-type: date
        updated_at:
          anyOf:
            - type: string
              format: date-time
              x-native-type: date
            - type: 'null'
      required:
        - id
        - workspace_id
        - title
        - description
        - rule_graph
        - created_at
        - updated_at
    RuleGraph:
      type: object
      properties:
        entry:
          type: string
        nodes:
          type: object
          propertyNames:
            type: string
          additionalProperties:
            anyOf:
              - type: object
                properties:
                  id:
                    type: string
                  type:
                    const: condition
                  position:
                    type: object
                    properties:
                      x:
                        type: number
                      'y':
                        type: number
                    required:
                      - x
                      - 'y'
                  field:
                    type: string
                  operator:
                    enum:
                      - eq
                      - neq
                      - in
                      - not_in
                      - contains
                      - not_contains
                      - gt
                      - lt
                      - gte
                      - lte
                      - regex
                    type: string
                  value:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                      - type: number
                  outputs:
                    type: object
                    properties:
                      'true':
                        anyOf:
                          - type: string
                          - type: 'null'
                      'false':
                        anyOf:
                          - type: string
                          - type: 'null'
                    required:
                      - 'true'
                      - 'false'
                required:
                  - id
                  - type
                  - position
                  - field
                  - operator
                  - value
                  - outputs
              - type: object
                properties:
                  id:
                    type: string
                  type:
                    const: split
                  position:
                    type: object
                    properties:
                      x:
                        type: number
                      'y':
                        type: number
                    required:
                      - x
                      - 'y'
                  variants:
                    type: array
                    minItems: 2
                    items:
                      type: object
                      properties:
                        weight:
                          type: number
                          minimum: 1
                          maximum: 100
                        target:
                          anyOf:
                            - type: string
                            - type: 'null'
                      required:
                        - weight
                        - target
                required:
                  - id
                  - type
                  - position
                  - variants
              - type: object
                properties:
                  id:
                    type: string
                  type:
                    const: destination
                  position:
                    type: object
                    properties:
                      x:
                        type: number
                      'y':
                        type: number
                    required:
                      - x
                      - 'y'
                  url:
                    type: string
                    format: uri
                required:
                  - id
                  - type
                  - position
                  - url
              - type: object
                properties:
                  id:
                    type: string
                  type:
                    const: transform
                  position:
                    type: object
                    properties:
                      x:
                        type: number
                      'y':
                        type: number
                    required:
                      - x
                      - 'y'
                  transforms:
                    type: object
                    properties:
                      query_params:
                        type: array
                        items:
                          type: object
                          properties:
                            key:
                              type: string
                              minLength: 1
                            value:
                              type: string
                            mode:
                              enum:
                                - set
                                - append
                              type: string
                          required:
                            - key
                            - value
                            - mode
                      redirect_status:
                        anyOf:
                          - const: 301
                          - const: 302
                          - const: 307
                          - const: 308
                      response_headers:
                        type: array
                        items:
                          type: object
                          properties:
                            key:
                              type: string
                              minLength: 1
                            value:
                              type: string
                              pattern: ^[^\r\n]*$
                            mode:
                              enum:
                                - set
                                - append
                              type: string
                          required:
                            - key
                            - value
                            - mode
                  next:
                    anyOf:
                      - type: string
                      - type: 'null'
                required:
                  - id
                  - type
                  - position
                  - transforms
                  - next
              - type: object
                properties:
                  id:
                    type: string
                  type:
                    const: password
                  position:
                    type: object
                    properties:
                      x:
                        type: number
                      'y':
                        type: number
                    required:
                      - x
                      - 'y'
                  next:
                    anyOf:
                      - type: string
                      - type: 'null'
                required:
                  - id
                  - type
                  - position
                  - next
              - type: object
                properties:
                  id:
                    type: string
                  type:
                    const: countdown
                  position:
                    type: object
                    properties:
                      x:
                        type: number
                      'y':
                        type: number
                    required:
                      - x
                      - 'y'
                  seconds:
                    type: integer
                    minimum: 1
                    maximum: 300
                  message:
                    anyOf:
                      - type: string
                        maxLength: 500
                      - type: 'null'
                  next:
                    anyOf:
                      - type: string
                      - type: 'null'
                required:
                  - id
                  - type
                  - position
                  - seconds
                  - message
                  - next
              - type: object
                properties:
                  id:
                    type: string
                  type:
                    const: webhook
                  position:
                    type: object
                    properties:
                      x:
                        type: number
                      'y':
                        type: number
                    required:
                      - x
                      - 'y'
                  url:
                    type: string
                    format: uri
                  method:
                    enum:
                      - POST
                      - GET
                    type: string
                  headers:
                    type: object
                    propertyNames:
                      type: string
                    additionalProperties:
                      type: string
                      pattern: ^[^\r\n]*$
                  next:
                    anyOf:
                      - type: string
                      - type: 'null'
                required:
                  - id
                  - type
                  - position
                  - url
                  - method
                  - next
              - type: object
                properties:
                  id:
                    type: string
                  type:
                    const: entry
                  position:
                    type: object
                    properties:
                      x:
                        type: number
                      'y':
                        type: number
                    required:
                      - x
                      - 'y'
                  next:
                    anyOf:
                      - type: string
                      - type: 'null'
                  starts_at:
                    anyOf:
                      - type: string
                        format: date-time
                      - type: 'null'
                  expires_at:
                    anyOf:
                      - type: string
                        format: date-time
                      - type: 'null'
                  fallback_url:
                    anyOf:
                      - type: string
                      - type: 'null'
                required:
                  - id
                  - type
                  - position
                  - next
                  - starts_at
                  - expires_at
                  - fallback_url
      required:
        - entry
        - nodes
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: A user or workspace API key, created in the dashboard settings.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.