---
title: "Diff one source file"
method: GET
path: "/websiteSourceCode/files/diff"
tags: ["Source code"]
---

# Diff one source file

`GET /websiteSourceCode/files/diff`

## Request

- Base URL: `https://api.cactal.ai/v1`
- URL: `https://api.cactal.ai/v1/websiteSourceCode/files/diff`
- Auth: HTTP bearer

Returns a bounded unified diff for one file name between two version refs, defaulting from published to head.

## Query parameters

- `websiteId` string, required
- `from` string: Base side of the diff: a version number, `head`, or `published`. Defaults to `published`.
- `to` string: Target side of the diff: a version number, `head`, or `published`. Defaults to `head`.
- `name` string, required: File name to compare.

## Response `200`

The selected file comparison and unified diff.

- object
  - `websiteId` string, required: Id of the website.
  - `name` string, required: Compared file name.
  - `fromVersion` integer, required: Resolved base version.
  - `toVersion` integer, required: Resolved target version.
  - `fromType` 'page' | 'component' | 'module' | 'server_function' | 'global_css' | 'not_found' | 'website_config' | 'custom_head_start' | 'custom_head_end' | 'custom_body_start' | 'custom_body_end': File type at the base version, when present.
  - `toType` 'page' | 'component' | 'module' | 'server_function' | 'global_css' | 'not_found' | 'website_config' | 'custom_head_start' | 'custom_head_end' | 'custom_body_start' | 'custom_body_end': File type at the target version, when present.
  - `status` 'added' | 'removed' | 'modified' | 'unchanged', required: How the file differs between the two versions.
  - `diff` string, required: Unified diff hunks.
  - `truncated` boolean: `true` when diff computation or output reached its bound. Read both versions for the full content.

## Other responses

- `400`: Validation failed. The response `message` names the first invalid field.
- `401`: Missing, invalid, expired, or revoked API key.
- `403`: The authenticated principal lacks the required capability.
- `404`: The resource does not exist or is outside the principal’s access scope.
- `429`: Rate limit exceeded. Retry after the number of seconds in the `Retry-After` header.

---

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