---
title: "Create a repository commit"
method: POST
path: "/v1/spaces/{spaceId}/source/commits"
tags: ["Git"]
---

# Create a repository commit

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

## Request

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

Save file operations as one Git commit. Spacefast creates a missing hosted repository for an initial commit. Send expectedHeadSha to reject stale writes. With sourceVersionId, preserve all original upload files before applying operations. The version must be current, ready, and a direct static upload. This option requires versions:read and versions:download in addition to spaces:write. Use 40 zeroes for expectedHeadSha and omit base or ephemeral branches. The hosted repository must have no branches, ephemeral branches, or tags. Upload bytes and replacement contents must total at most 4 MiB, with at most 1,000 uploaded files. A commit does not confirm deployment.

## Path parameters

- `spaceId` string, required

## Request body

- object
  - `connectionType` 'connected' | 'hosted', required
  - `targetBranch` string, required
  - `commitMessage` string, required
  - `operations` union[], required: File operations to save together in one Git commit. Maximum 100 paths and 4 MiB of combined contents.
    - union
      - object
        - `action` 'upsert', required
        - `path` string, required: Exact file path from the repository root. Use forward slashes. Do not add a leading slash.
        - `contents` string, required: Complete replacement contents. Maximum 1 MiB in the request encoding. Omitted files do not change.
        - `mode` '100644' | '100755' | '120000' | '160000'
        - `encoding` 'utf8' | 'base64' | 'hex'
      - object
        - `action` 'delete', required
        - `path` string, required: Exact file path from the repository root. Use forward slashes. Do not add a leading slash.
  - `expectedHeadSha` string: Commit SHA the caller read from the target branch. The write fails if the branch changed.
  - `sourceVersionId` string: Initialize hosted source from this original static upload before applying operations. Requires a zero expectedHeadSha and version read/download permissions.
  - `baseBranch` string
  - `ephemeral` boolean
  - `ephemeralBase` boolean
  - `author` object: Git author. Omit it to use the registered profile of the authenticated user or machine credential creator. Attribution does not change permissions.
    - `name` string, required
    - `email` string, email, required
  - `committer` object
    - `name` string, required
    - `email` string, email, required

## Response `201`

Response for status 201

- 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
    - `commitSha` string, required
    - `treeSha` string, required
    - `targetBranch` string, required
    - `packBytes` integer, required
    - `blobCount` integer, required
    - `refUpdate` object, required
      - `branch` string, required
      - `oldSha` string, required
      - `newSha` string, 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)
