---
title: "Read a site's source file"
method: GET
path: "/sites/{id}/source/file"
tags: ["Sites"]
---

# Read a site's source file

`GET /sites/{id}/source/file`

## Request

- Base URL: `https://api.crevio.co/v1`
- URL: `https://api.crevio.co/v1/sites/{id}/source/file`
- Auth: API key in header `Authorization`

Returns one file from the site's repository at `ref`, `main` by default. Text comes back as-is with `encoding: utf8`; content that is not valid UTF-8 (images, fonts) comes back base64-encoded with `encoding: base64`. Files over 4 MiB are refused with `422`. A path that is not a file at `ref` answers `404`.

`ref` is a branch, a tag or a commit sha; an unknown one answers `404` with `param: ref`. Every read reports `commit_sha`, the commit it read, so later reads can pass it as `ref` to stay on one revision, and `head_sha`, where `main` is now, to pass as `expected_head_sha` when you commit.

Fails with `422 repository_missing` when the site has no repository yet, and `503 repository_unreachable` when its repository does not answer in time (retry).

## Path parameters

- `id` string, required

## Query parameters

- `path` string, required
- `ref` string

## Response `200`

The file

- object
  - `object` 'site_source_file', required
  - `head_sha` string, required: Where `main` points now. Pass it as `expected_head_sha` when you commit.
  - `ref` string, required: The `ref` this read asked for: `main` unless you passed one.
  - `commit_sha` string, required: The commit `ref` resolved to, which this answer was read at. Pass it as `ref` to read more of the same revision.
  - `path` string, required
  - `sha` string, required: The file's git blob id.
  - `size` integer, required: Bytes.
  - `encoding` 'utf8' | 'base64', required
  - `content` string, required: The file's content, encoded as `encoding` says.

## Other responses

- `401`: Authentication required
- `404`: Resource not found
- `422`: Validation error
- `429`: Rate limit exceeded — 600 requests per minute per owner on the free tier: every API key and OAuth token one person holds on an account shares one budget, and the account's team keys share another. Retry after the number of seconds in `Retry-After`.
- `503`: Feature not configured for this workspace

## Changes

- **2026-11-15** `56c22ab9b282`: 5 warning
  - added the new `idempotency_error` enum value to the `error/type` response property for the response status `401`
  - added the new `idempotency_error` enum value to the `error/type` response property for the response status `404`
  - added the new `idempotency_error` enum value to the `error/type` response property for the response status `422`
  - added the new `idempotency_error` enum value to the `error/type` response property for the response status `429`
  - …1 more
- **2026-11-15** `3d2d9bae7da4`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/crevio/apis/crevio-api-v1/changes/sites/:id/source/file/get.md)

---

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