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

# Download a project file

> Returns raw file bytes with content headers forwarded from Design Engine. Successful download responses are not wrapped in the JSON success envelope used by other project read endpoints.



## OpenAPI

````yaml /openapi/davinci-public.v2.yaml get /api/v2/programmatic/projects/{projectId}/files/{fileId}
openapi: 3.1.0
info:
  title: Davinci Public API
  version: 2.0.0
  description: >-
    Public Routing Server API contract for Davinci integrations and official
    SDKs.
servers:
  - url: https://davinci-app.com
    description: Production
security:
  - ApiKeyBearer: []
tags:
  - name: Meta
    description: API metadata and health checks.
  - name: Projects
    description: Read project metadata, trees, objects, and attached files.
paths:
  /api/v2/programmatic/projects/{projectId}/files/{fileId}:
    get:
      tags:
        - Projects
      summary: Download a project file
      description: >-
        Returns raw file bytes with content headers forwarded from Design
        Engine. Successful download responses are not wrapped in the JSON
        success envelope used by other project read endpoints.
      operationId: downloadProjectFile
      parameters:
        - $ref: '#/components/parameters/ProjectId'
        - $ref: '#/components/parameters/FileId'
        - $ref: '#/components/parameters/Branch'
      responses:
        '200':
          description: Raw file bytes. This response is not a JSON envelope.
          headers:
            Content-Type:
              schema:
                type: string
            Content-Disposition:
              schema:
                type: string
            Content-Length:
              schema:
                type: integer
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        '401':
          $ref: '#/components/responses/InvalidApiKey'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/FileNotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
        '503':
          description: >-
            Project acquisition unavailable. Common error codes include
            `PROJECT_NOT_READY`, `SERVICE_UNAVAILABLE`, and
            `SERVER_NOT_AVAILABLE`.
          headers:
            Retry-After:
              schema:
                type: integer
                minimum: 1
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
      security:
        - ApiKeyBearer: []
      x-codeSamples:
        - lang: typescript
          label: TypeScript SDK
          source: >
            import { writeFile } from 'node:fs/promises';

            import { DavinciClient } from '@celedon/davinci-sdk';


            const client = new DavinciClient({
              apiKey: process.env.DAVINCI_API_KEY!,
            });


            const download = await client.projects.downloadFile('project-id',
            'file-id', {
              branch: 'main',
            });

            await writeFile('downloaded-file', download.buffer);

            console.log(download.contentType, download.contentLength);
        - lang: python
          label: Python SDK
          source: |
            import os
            from davinci_sdk import DavinciClient

            with DavinciClient(api_key=os.environ["DAVINCI_API_KEY"]) as client:
                download = client.projects.download_file("project-id", "file-id", branch="main")
                with open("downloaded-file", "wb") as file:
                    file.write(download.content)
                print(download.content_type, download.content_length)
components:
  parameters:
    ProjectId:
      name: projectId
      in: path
      required: true
      schema:
        type: string
        minLength: 1
      description: Project id. May be compound in the form `{projectId}--{branchName}`.
    FileId:
      name: fileId
      in: path
      required: true
      schema:
        type: string
        minLength: 1
      description: Reference object id or storage filename.
    Branch:
      name: branch
      in: query
      required: false
      schema:
        type: string
        default: main
  responses:
    InvalidApiKey:
      description: Missing, invalid, expired, or inactive API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    Forbidden:
      description: Caller is authenticated but not authorized.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    FileNotFound:
      description: File does not exist in the project.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    RateLimited:
      description: API key request rate exceeded.
      headers:
        Retry-After:
          schema:
            type: integer
            minimum: 1
          description: Seconds to wait before retrying.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    InternalError:
      description: Unexpected server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
  schemas:
    ErrorEnvelope:
      type: object
      required:
        - success
        - error
      properties:
        success:
          type: boolean
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
            message:
              type: string
            details:
              type: object
              additionalProperties: true
          additionalProperties: true
      additionalProperties: true
  securitySchemes:
    ApiKeyBearer:
      type: http
      scheme: bearer
      bearerFormat: dav_ak_live_... or dav_ak_test_...
      x-default: dav_ak_live_your_token
      description: >-
        Personal access token. Programmatic reads require the projects:read
        scope.

````