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

# Get snippet details

> Returns a snippet including its code and display type.



## OpenAPI

````yaml /openapi.json get /v1/snippets/{id}
openapi: 3.1.0
info:
  title: CNAP API
  version: 1.0.0
  description: >-
    Public API for managing CNAP workspaces, clusters, templates, products, and
    deployments.


    Authenticate with a Personal Access Token via the `Authorization: Bearer
    cnap_pat_...` header.


    Workspace-scoped endpoints require the `X-Workspace-Id` header.
servers:
  - url: https://api.cnap.tech
    description: Production
security: []
paths:
  /v1/snippets/{id}:
    get:
      tags:
        - Snippets
      summary: Get snippet details
      description: Returns a snippet including its code and display type.
      parameters:
        - schema:
            type: string
            description: Snippet ID
          required: true
          description: Snippet ID
          name: id
          in: path
      responses:
        '200':
          description: Snippet details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Snippet'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Snippet not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - BearerAuth: []
components:
  schemas:
    Snippet:
      type: object
      properties:
        id:
          type: string
          example: j572abc123def456
        name:
          type: string
          example: Cluster Resource Audit
        description:
          type:
            - string
            - 'null'
          example: Checks resource requests and limits
        code:
          type: string
          example: async () => { ... }
          description: >-
            Async JavaScript function body executed in a sandboxed V8 isolate.
            Has access to cnap.request() for API calls.
        display_type:
          type: string
          enum:
            - table
            - stat
            - json
            - logs
          description: Controls how the snippet result is rendered in dashboard widgets
          example: table
        workspace_id:
          type: string
          example: j572abc123def456
        created_by:
          type: string
          description: User ID of the snippet creator
        created_at:
          type: number
          description: Unix timestamp (seconds)
      required:
        - id
        - name
        - description
        - code
        - display_type
        - workspace_id
        - created_by
        - created_at
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: not_found
            message:
              type: string
              example: Resource not found
            param:
              type: string
              description: The request field that caused the error
              example: name
            suggestion:
              type: string
              example: Run `cnap clusters list` to see available clusters
            details: {}
          required:
            - code
            - message
      required:
        - error
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Personal Access Token (cnap_pat_...) or OAuth2 JWT. Create tokens at
        https://cnap.tech/account/tokens

````