# Compare source commits

Compare one source commit with another source commit. The first parent is the default base. Set `maxPatchBytes` to limit the total patch text.

## API Endpoint

GET `/v1/spaces/{spaceId}/source/commit-diff`

## Authorization

- `Authorization` Bearer token · header required

`Authorization: Bearer <token>` with an API key (`sfa_` prefix), an OAuth access token, a session token, or a Space machine credential (`sfm_` prefix).
  
- `Authorization` OAuth2 access token · header required

OAuth 2.0 with Spacefast scopes. People use the authorization code flow; machines use client credentials.

### Scopes:
- `spaces:read`

## Path parameters

- `spaceId`: string (required)

## Query parameters

- `baseSha`: string (min length 1)
- `branch`: string (min length 1)
- `connectionType`: string (required, default: "connected")  
  Allowed: `connected`, `hosted`
- `maxPatchBytes`: integer (required, max 262144, default: 65536)
- `patch`: boolean (required, default: true)
- `path`: string | string[]
- `savedOnly`: boolean
- `sha`: string (required, min length 1)

## Responses

### 200 Response for status 200

```json
{
  "$schema": "string<uri>",
  "data": {
    "baseSha": "string",
    "files": [
      {
        "additions": -9007199254740991,
        "changes": -9007199254740991,
        "deletions": -9007199254740991,
        "oldPath": "string",
        "patch": "string",
        "patchTruncated": true,
        "path": "string",
        "state": "string"
      }
    ],
    "filteredFiles": [
      {
        "path": "string",
        "oldPath": "string",
        "state": "string"
      }
    ],
    "repositoryConnection": {
      "id": "string",
      "spaceId": "string",
      "provider": "github",
      "connectionType": "connected",
      "repositoryId": "string",
      "installationId": null,
      "cloneUrlConfigured": false,
      "upstreamUrlConfigured": false,
      "repositoryName": "string",
      "repositoryFullName": "string",
      "defaultBranch": "string",
      "productionBranch": "string",
      "credentialConfigured": true,
      "autoDeployProduction": true,
      "autoDeployPreviews": true,
      "buildSettings": {
        "rootDirectory": null,
        "installDirectory": null,
        "installCommand": null,
        "buildCommand": null,
        "outputDirectory": null,
        "ignoredBuildCommand": null,
        "frameworkPreset": null,
        "platformPreset": null,
        "allowUnsupportedPlatformFeatures": false,
        "timeoutSeconds": 900
      },
      "syncStatus": "idle",
      "providerAccessStatus": "active",
      "providerAccessError": null,
      "lastSyncedAt": "2019-08-24T14:15:22Z",
      "lastSyncError": "string",
      "syncRunId": "string",
      "connectedUserId": "string",
      "createdAt": "2019-08-24T14:15:22Z",
      "updatedAt": "2019-08-24T14:15:22Z"
    },
    "repositoryId": "string",
    "sha": "string",
    "stats": {
      "files": -9007199254740991,
      "additions": -9007199254740991,
      "deletions": -9007199254740991,
      "changes": -9007199254740991
    }
  }
}
```

### Error Response

```json
{
  "$schema": "string<uri>",
  "type": "string",
  "title": "string",
  "status": -9007199254740991,
  "detail": "string",
  "code": "string",
  "pointer": "string",
  "details": {
    "property1": null,
    "property2": null
  },
  "suggestions": [
    "string"
  ],
  "next": [
    "string"
  ],
  "requestId": "string"
}
```
