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

# Get a UI template by ID

> Get a UI template by ID with CSP configuration from database.

Database is determined from the template_id (format: {api_name}::{operation_id}::{type}).
The api_name URL parameter is ignored for DB routing.

CSP Configuration:
- Only uses manually configured CSP stored in the database (csp_config or ui_meta.csp)
- If no CSP is configured, returns empty CSP (self-contained, no external resources)
- All CSP fields are always included (empty arrays as placeholders when not needed)

Args:
    api_name: API name (ignored, kept for URL compatibility)
    template_id: Unique identifier for the template

Returns:
    UITemplateResponse with template ID, HTML content, and CSP configuration (all fields included)

Raises:
    HTTPException 404: If template not found



## OpenAPI

````yaml get /api/ui-templates/{api_name}/{template_id}
openapi: 3.1.0
info:
  title: Apigene
  description: Apigene API
  version: 1.0.0
  contact:
    name: Apigene Support
    url: https://app.apigene.ai
    email: support@apigene.ai
servers:
  - url: https://app.apigene.ai
security:
  - BearerAuth: []
paths:
  /api/ui-templates/{api_name}/{template_id}:
    get:
      tags:
        - UI Templates
      summary: Get a UI template by ID
      description: >-
        Get a UI template by ID with CSP configuration from database.


        Database is determined from the template_id (format:
        {api_name}::{operation_id}::{type}).

        The api_name URL parameter is ignored for DB routing.


        CSP Configuration:

        - Only uses manually configured CSP stored in the database (csp_config
        or ui_meta.csp)

        - If no CSP is configured, returns empty CSP (self-contained, no
        external resources)

        - All CSP fields are always included (empty arrays as placeholders when
        not needed)


        Args:
            api_name: API name (ignored, kept for URL compatibility)
            template_id: Unique identifier for the template

        Returns:
            UITemplateResponse with template ID, HTML content, and CSP configuration (all fields included)

        Raises:
            HTTPException 404: If template not found
      operationId: ui_template_get
      parameters:
        - name: api_name
          in: path
          required: true
          schema:
            type: string
            title: Api Name
        - name: template_id
          in: path
          required: true
          schema:
            type: string
            title: Template Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UITemplateResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - BearerAuth: []
components:
  schemas:
    UITemplateResponse:
      properties:
        id:
          type: string
          title: Id
          description: Template ID
        html:
          type: string
          title: Html
          description: HTML content
        is_default:
          type: boolean
          title: Is Default
          description: Whether this is the default template for the operation
          default: false
        ui_meta:
          anyOf:
            - $ref: '#/components/schemas/UIResourceMeta'
            - type: 'null'
          description: >-
            UI resource metadata with all advanced settings: CSP, permissions
            (camera, microphone, geolocation, clipboardWrite), domain, and
            prefersBorder
        template_format:
          type: string
          title: Template Format
          description: 'Template format: mcp-app or handlebars'
          default: mcp-app
      type: object
      required:
        - id
        - html
      title: UITemplateResponse
      description: |-
        Response containing UI template data with all advanced settings.

        Includes:
        - HTML content for rendering
        - UI metadata (ui_meta) with all advanced settings:
          * CSP: Content Security Policy
          * Permissions: camera, microphone, geolocation, clipboardWrite
          * Domain: Dedicated origin for view
          * PrefersBorder: Visual boundary preference
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    UIResourceMeta:
      properties:
        csp:
          anyOf:
            - $ref: '#/components/schemas/CSPConfig'
            - type: 'null'
          description: >-
            Content Security Policy configuration for external resources
            (images, scripts, fonts, API calls, iframes)
        permissions:
          anyOf:
            - $ref: '#/components/schemas/PermissionsConfig'
            - type: 'null'
          description: >-
            Sandbox permissions requested by the UI (camera, microphone,
            geolocation, clipboardWrite)
        domain:
          anyOf:
            - type: string
            - type: 'null'
          title: Domain
          description: >-
            Dedicated origin for view (host-dependent format). Used for isolated
            iframe contexts.
        prefersBorder:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Prefersborder
          description: >-
            Visual boundary preference: true=show border around iframe, false=no
            border (seamless integration)
      type: object
      title: UIResourceMeta
      description: >-
        UI resource metadata configuration per MCP Apps spec.


        Includes all advanced settings:

        - CSP: Content Security Policy for external resources

        - Permissions: Sandbox permissions (camera, microphone, geolocation,
        clipboardWrite)

        - Domain: Dedicated origin for the view

        - PrefersBorder: Visual boundary preference
    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
    CSPConfig:
      properties:
        resourceDomains:
          items:
            type: string
          type: array
          title: Resourcedomains
          description: >-
            Origins for static resources (images, scripts, stylesheets, fonts,
            media)
        connectDomains:
          items:
            type: string
          type: array
          title: Connectdomains
          description: Origins for network requests (fetch/XHR/WebSocket)
        frameDomains:
          items:
            type: string
          type: array
          title: Framedomains
          description: Origins for nested iframes
        baseUriDomains:
          items:
            type: string
          type: array
          title: Baseuridomains
          description: Allowed base URIs for the document
      type: object
      title: CSPConfig
      description: CSP configuration for UI templates.
    PermissionsConfig:
      properties:
        camera:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Camera
          description: Request camera access. Set to {} to request permission.
        microphone:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Microphone
          description: Request microphone access. Set to {} to request permission.
        geolocation:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Geolocation
          description: Request geolocation access. Set to {} to request permission.
        clipboardWrite:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Clipboardwrite
          description: Request clipboard write access. Set to {} to request permission.
      type: object
      title: PermissionsConfig
      description: >-
        Permissions configuration for UI templates.


        Each permission is an empty object {} when requested, or omitted if not
        needed.

        These permissions are requested from the host when the UI is loaded.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        JWT Authorization header using the Bearer scheme. Example:
        'Authorization: Bearer {token}'

````