---
title: "Merge repository branches"
method: POST
path: "/v1/spaces/{spaceId}/source/merge"
tags: ["Git"]
---

# Merge repository branches

`POST /v1/spaces/{spaceId}/source/merge`

## Request

- Base URL: `https://api.spacefast.com`
- URL: `https://api.spacefast.com/v1/spaces/{spaceId}/source/merge`
- 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:write`)

Merge branches in a hosted repository. Send expectedTargetSha to reject changes if the target branch moved. A merge does not confirm deployment.

## Path parameters

- `spaceId` string, required

## Request body

- object
  - `connectionType` 'connected' | 'hosted', required
  - `sourceBranch` string, required
  - `targetBranch` string, required
  - `strategy` 'merge' | 'ff_only' | 'ff_prefer'
  - `sourceIsEphemeral` boolean
  - `targetIsEphemeral` boolean
  - `expectedTargetSha` string
  - `commitMessage` string
  - `author` object
    - `name` string, required
    - `email` string, email, required
  - `committer` object
    - `name` string, required
    - `email` string, email, required
  - `allowUnrelatedHistories` boolean
  - `squash` boolean

## 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
    - `repositoryId` string, required
    - `result` 'merge_commit' | 'fast_forward' | 'no_op' | 'squash' | 'unknown', required
    - `commitSha` string, required
    - `treeSha` string, required
    - `source` object, required
      - `branch` string, required
      - `ephemeral` boolean, required
      - `sha` string, required
    - `target` object, required
      - `branch` string, required
      - `ephemeral` boolean, required
      - `oldSha` string, required
      - `newSha` string, required
    - `mergeBaseSha` string, nullable, required
    - `promotedCommits` integer, 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)
