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

# Compile Malloy source code

> Compiles Malloy source code in the context of a specific model file.
The submitted source is appended to the full model content, giving it
access to all sources, imports, and queries defined in the model.
Relative imports resolve correctly against sibling model files.
Returns compilation status and any problems (errors or warnings) found.




## OpenAPI

````yaml /dataplane-public-api-doc.yaml post /projects/{projectName}/packages/{packageName}/models/{path}/compile
openapi: 3.1.0
info:
  title: Malloy Publisher - Semantic Model Serving API
  description: >
    The Malloy Publisher - Semantic Model Serving API provides comprehensive
    access to Malloy packages and their associated resources.

    A Malloy package is a directory containing Malloy models (.malloy files),
    Malloy notebooks (.malloynb files), and embedded databases

    (.parquet files) with a malloy-publisher.json manifest at the package's root
    directory.


    ## Key Features


    - **Project Management**: Create and manage projects with their associated
    packages and connections

    - **Package Lifecycle**: Full CRUD operations for Malloy packages and their
    versions

    - **Model & Notebook Access**: Retrieve and execute Malloy models and
    notebooks

    - **Connection Management**: Secure database connection configuration and
    testing

    - **Query Execution**: Execute queries against models and retrieve results

    - **Watch Mode**: Real-time file watching for development workflows


    ## Resource Hierarchy


    The API follows a hierarchical resource structure:

    ```

    Projects

    ├── Connections

    └── Packages
        ├── Models
        ├── Notebooks
        └── Databases
    ```


    For examples, see the Malloy samples packages
    (https://github.com/malloydata/malloy-samples) repository.
  version: v0
servers:
  - url: https://{organization}.data.credibledata.com/api/v0/
    description: Production API server
    variables:
      organization:
        default: demo
        description: Your organization subdomain
security:
  - bearerAuth: []
tags:
  - name: publisher
    description: Publisher status and health check operations
  - name: projects
    description: >-
      Project lifecycle management including creation, configuration, and
      deletion of data modeling projects
  - name: connections
    description: >-
      Database connection management for secure data source configuration and
      access
  - name: packages
    description: >-
      Package management for Malloy data models, including versioning and
      distribution
  - name: models
    description: Malloy model access and compilation operations
  - name: notebooks
    description: Malloy notebook access and execution operations
  - name: databases
    description: Embedded database management and access
  - name: watch-mode
    description: Real-time file watching for development workflows
paths:
  /projects/{projectName}/packages/{packageName}/models/{path}/compile:
    post:
      tags:
        - models
      summary: Compile Malloy source code
      description: |
        Compiles Malloy source code in the context of a specific model file.
        The submitted source is appended to the full model content, giving it
        access to all sources, imports, and queries defined in the model.
        Relative imports resolve correctly against sibling model files.
        Returns compilation status and any problems (errors or warnings) found.
      operationId: compile-model-source
      parameters:
        - name: projectName
          in: path
          description: Name of the project
          required: true
          schema:
            $ref: '#/components/schemas/IdentifierPattern'
        - name: packageName
          in: path
          description: Name of the package
          required: true
          schema:
            type: string
        - name: path
          in: path
          description: >-
            Path to the model within the package (used to resolve relative
            imports)
          required: true
          schema:
            $ref: '#/components/schemas/PathPattern'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CompileRequest'
      responses:
        '200':
          description: Compilation result with status and any problems
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CompileResult'
        '400':
          $ref: '#/components/responses/BadRequest'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
components:
  schemas:
    IdentifierPattern:
      type: string
      pattern: ^[a-zA-Z0-9_-]+$
      description: Standard identifier pattern for resource names
    PathPattern:
      type: string
      pattern: ^[a-zA-Z0-9_/.-]+$
      description: Path pattern supporting slashes, dots, and dashes
    CompileRequest:
      type: object
      description: Request body for compiling Malloy source code
      properties:
        source:
          type: string
          description: Malloy source code to compile
        includeSql:
          type: boolean
          default: false
          description: >-
            If true, returns the generated SQL alongside compilation results
            (only available when compilation succeeds and the source contains a
            runnable query).
      required:
        - source
    CompileResult:
      type: object
      description: Result of a Malloy source compilation check
      properties:
        status:
          type: string
          description: >-
            Overall compilation status — "error" if any problems have error
            severity
          enum:
            - success
            - error
        problems:
          type: array
          description: List of compilation problems (errors and warnings)
          items:
            $ref: '#/components/schemas/CompileProblem'
        sql:
          type: string
          description: >-
            Generated SQL for the compiled query. Only present when includeSql
            is true and compilation succeeds with a runnable query.
    CompileProblem:
      type: object
      description: A compilation problem reported by the Malloy compiler
      properties:
        message:
          type: string
          description: Human-readable problem description
        severity:
          type: string
          description: Severity level of the problem
          enum:
            - error
            - warn
            - debug
        code:
          type: string
          description: Machine-readable error code
        at:
          type: object
          description: Source location of the problem
          properties:
            url:
              type: string
              description: URL of the source file
            range:
              type: object
              description: Character range within the source file
    Error:
      type: object
      description: Standard error response format
      properties:
        message:
          type: string
          description: Human-readable error message describing what went wrong
        details:
          type: string
          description: Additional error details or context
      required:
        - message
  responses:
    BadRequest:
      description: >-
        The request was malformed or cannot be performed given the current state
        of the system
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: The specified resource was not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InternalServerError:
      description: The server encountered an internal error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ServiceUnavailable:
      description: >-
        The service is temporarily unavailable, typically due to initialization,
        or draining state (Rolling updates, etc.)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````