---
title: "Read a source file"
method: GET
path: "/v1/spaces/{spaceId}/source/file"
tags: ["Git"]
---

# Read a source file

`GET /v1/spaces/{spaceId}/source/file`

## Request

- Base URL: `https://api.spacefast.com`
- URL: `https://api.spacefast.com/v1/spaces/{spaceId}/source/file`
- Auth: one of:
  - HTTP bearer
  - OAuth 2 (authorization code, authorization URL `https://api.spacefast.com/v1/auth/oauth2/authorize`, token URL `https://api.spacefast.com/v1/auth/oauth2/token`; client credentials, token URL `https://api.spacefast.com/v1/auth/oauth2/token`, scopes: `spaces:read`)

Read one source file at a branch, tag, or commit SHA. Use head for metadata without file contents.

## Path parameters

- `spaceId` string, required

## Query parameters

- `connectionType` 'connected' | 'hosted': Which of the space's repository connections to act on: `connected` for the repository you linked from a provider, `hosted` for the one Spacefast hosts and you push to.
- `ref` string: Branch, tag, or commit SHA to read. Defaults to the repository's default branch.
- `path` string, required: Exact file path from the repository root. Use forward slashes. Do not add a leading slash.
- `head` string: Return the file's metadata only, with `content` null.
- `maxBytes` integer: Maximum file content to read. The limit is 1 MiB.

## Response `200`

Response for status 200

- object
  - `$schema` string, uri: Canonical JSON Schema URL for this response body. The server also sends it in the `Link: rel="describedby"` response header.
  - `data` object, required
    - `repositoryConnection` object, required
      - `id` string, required: Repository connection id (`rpc_`).
      - `spaceId` string, required
      - `provider` 'github' | 'gitlab' | 'bitbucket' | 'generic', required: Git host family for the repository connection.
      - `connectionType` 'connected' | 'hosted', required
      - `repositoryId` string, nullable, required
      - `installationId` string, nullable, required: Repository app installation id, when configured.
      - `cloneUrlConfigured` boolean, required: Whether a repository clone URL is configured.
      - `upstreamUrlConfigured` boolean, required: Whether an upstream repository URL is configured.
      - `forkState` object, nullable: Initial main-branch remix progress, backed by its durable operation.
        - `copied` boolean, required
        - `status` 'queued' | 'running' | 'succeeded' | 'failed' | 'canceled', required
      - `repositoryName` string, required
      - `repositoryFullName` string, required
      - `defaultBranch` string, required
      - `productionBranch` string, required
      - `credentialConfigured` boolean, required
      - `autoDeployProduction` boolean, required
      - `autoDeployPreviews` boolean, required
      - `githubPreviewCommentsEnabled` boolean, nullable: Controls GitHub preview comments for this Space. Set null to use the team setting.
      - `buildSettings` object, required: Resolved build settings. Builds persist this as an immutable `settingsSnapshot`.
        - `rootDirectory` string, nullable, required
        - `installDirectory` string, nullable, required
        - `installCommand` string, nullable, required
        - `buildCommand` string, nullable, required
        - `outputDirectory` string, nullable, required
        - `ignoredBuildCommand` string, nullable, required
        - `frameworkPreset` string, nullable, required
        - `platformPreset` string, nullable, required
        - `allowUnsupportedPlatformFeatures` boolean, required
        - `timeoutSeconds` integer, required
      - `syncStatus` 'idle' | 'syncing' | 'ready' | 'failed', required
      - `providerAccessStatus` 'active' | 'suspended' | 'revoked' | 'reauthorization_required', required
      - `providerAccessError` string, nullable, required
      - `lastSyncedAt` string, date-time, nullable, required
      - `lastSyncError` string, nullable, required
      - `syncRunId` string, nullable, required
      - `connectedUserId` string, nullable, required
      - `createdAt` string, date-time, required
      - `updatedAt` string, date-time, required
    - `ref` string, required
    - `path` string, required
    - `content` string, nullable, required
    - `metadata` object, nullable, required
      - `status` integer, nullable, required
      - `blobSha` string, nullable, required
      - `lastCommitSha` string, nullable, required
      - `size` integer, nullable, required
      - `etag` string, nullable, required
      - `lastModified` string, nullable, required
      - `contentType` string, nullable, required

## Other responses

- `default`: Problem details (RFC 9457). Any 4xx/5xx response is one `application/problem+json` document.

---

[API](https://skmtc.dev/spacefast/apis/spacefast-api.md) · [All operations](https://skmtc.dev/spacefast/apis/spacefast-api/llms.txt) · [OpenAPI document](https://skmtc.dev/spacefast/apis/spacefast-api/revisions/bd165bc7c983?raw)
