# Compare source branches

Compare one source branch with another branch. The default branch is the base if you do not set `base`.

GET `/v1/spaces/{spaceId}/source/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).

or

### `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

- `connectionType` string required
  - default: "connected"
  - Allowed: `connected`, `hosted`
- `branch` string required (min length 1)
- `base` string (min length 1)
- `ephemeral` boolean
- `ephemeralBase` boolean
- `path` string | string[]
- `patch` boolean required (default: false)

## Responses

### 200 Response for status 200

- `$schema` string <uri>
- `data` object required
  - `repositoryConnection` object required
    - `id` string required
    - `spaceId` string required
    - `provider` string required
      - Allowed: `github`, `gitlab`, `bitbucket`, `generic`
    - `connectionType` string required
      - `connected` or `hosted`
    - `repositoryId` string | any required
    - `installationId` string | any required
      - default: null
    - `cloneUrlConfigured` boolean required (default: false)
    - `upstreamUrlConfigured` boolean required (default: false)
    - `repositoryName` string required
    - `repositoryFullName` string required
    - `defaultBranch` string required
    - `productionBranch` string required
    - `credentialConfigured` boolean required
    - `autoDeployProduction` boolean required
    - `autoDeployPreviews` boolean required
    - `buildSettings` object required
      - `rootDirectory` string | any required
      - `installDirectory` string | any required
      - `installCommand` string | any required
      - `buildCommand` string | any required
      - `outputDirectory` string | any required
      - `ignoredBuildCommand` string | any required
      - `frameworkPreset` string | any required
      - `platformPreset` string | any required
      - `allowUnsupportedPlatformFeatures` boolean required (default: false)
      - `timeoutSeconds` integer required (default: 900)
    - `syncStatus` string required
      - Allowed: `idle`, `syncing`, `ready`, `failed`
    - `providerAccessStatus` string required
      - default: "active"
      - Allowed: `active`, `suspended`, `revoked`, `reauthorization_required`
    - `providerAccessError` string | any required
    - `lastSyncedAt` string<date-time> | any required
    - `lastSyncError` string | any required
    - `syncRunId` string | any required
    - `connectedUserId` string | any required
    - `createdAt` string<date-time> required
    - `updatedAt` string<date-time> required
  - `repositoryId` string required
  - `branch` string required
  - `base` string required
  - `stats` object required
    - `files` integer required
    - `additions` integer required
    - `deletions` integer required
    - `changes` integer required
  - `files` object[] required
    - `path` string required
    - `oldPath` string | any required
    - `state` string required
    - `additions` integer required
    - `deletions` integer required
    - `changes` integer required
    - `patch` string | any required

### Error Response

- `$schema` string <uri>
- `type` string required
- `title` string required
- `status` integer required
- `detail` string required
- `code` string required
- `pointer` string
- `details` object
- `suggestions` string[]
- `next` string[]
- `requestId` string required

## Try it

### cURL Example

```bash
curl -X GET "https://api.spacefast.com/v1/spaces/string/source/diff?connectionType=connected&branch=string&patch=false" \
  -H "Authorization: Bearer YOUR_TOKEN"
```

### JavaScript Example

```javascript
const response = await fetch("https://api.spacefast.com/v1/spaces/string/source/diff?connectionType=connected&branch=string&patch=false", {
  method: "GET",
  headers: {
    "Authorization": "Bearer YOUR_TOKEN"
  }
});
```

### Python Example

```python
import requests

response = requests.get(
    "https://api.spacefast.com/v1/spaces/string/source/diff?connectionType=connected&branch=string&patch=false",
    headers={
        "Authorization": "Bearer YOUR_TOKEN"
    },
)
```
