---
raw: true
search:
  tags:
    - Versions
    - POST
seo:
  description: >-
    Creates a version and returns upload instructions. The declared file…
    Reference for the POST /v1/spaces/{spaceId}/versions endpoint in the
    Spacefast API.
sidebar:
  label: Start a new version upload
  badge: POST
title: Start a new version upload
type: openapi-operation
---
Creates a version and returns upload instructions. The declared file manifest drives change-only uploads: unchanged files are retained from the previous version and only the remainder is requested.

`POST /v1/spaces/{spaceId}/versions`

**Request body** (`application/json`, required)

- `source` (object) — Publish provenance recorded on the version; defaults to {kind: "direct\_upload"}.
- `publishMode` (string) — How to interpret omitted paths in \`files\`: \`additive\` retains existing paths unless explicitly replaced; \`snapshot\` treats \`files\` as the complete desired manifest.
- `sourceMetadata` (object) — Additional control-plane-only provenance for build and deploy read models.
- `buildLog` (string) — Build transcript truncated to a bounded size for deploys that ran a local build before publishing.
- `finalize` (object) — Finalize intent for a declared upload. The version finalizes itself once Spacefast confirms every declared file landed: at create when nothing needs uploading, otherwise on the \`uploads/refresh\` call that finds nothing pending. Call refresh after the last upload. The explicit finalize call remains available for recovery and replay.
- `files` (object[], required) — The complete desired file manifest. \`sha256\` is optional: omit it to upload by path and let the runtime hash the bytes, or include it to upload by content address, with the digest verified as the bytes land. A \`sourceUrl\` entry is fetched and hashed by the runtime.
- `configOnly` (boolean) — Recompile the configuration on top of the current ready artifact without replacing content: the file catalog carries forward, Functions/Zero declarations and runtime detection are preserved, and the version records a \`config\_update\` source. \`files\` may name only \`sf.jsonc\` (the shipped configuration); every other path keeps the current version's bytes. Requires an existing ready version to carry forward. Runtime changes still need a normal content publish.
- `deletePaths` (string[]) — Explicit paths to remove when \`publishMode\` is additive. Omitted paths are retained. Only listed paths are deleted.
- `immutableAssetPrefixes` (string[]) — Publisher-owned directory prefixes whose declared files are immutable generation assets. Snapshot publishes retain the matching files from the current generation for exactly one subsequent generation.

Request body example:

```json
{
  "source": {
    "kind": "direct_upload",
    "client": "string",
    "branch": "string",
    "commit": "string",
    "message": "string",
    "dirty": true,
    "metadata": {
      "property1": "string",
      "property2": "string"
    },
    "git": {
      "repository": "string",
      "repositoryFullName": "string",
      "repositoryUrl": "string",
      "ref": "string",
      "branch": "string",
      "branchAliasUrl": "string",
      "commit": "string",
      "commitSha": "string",
      "pullRequestNumber": 0,
      "property1": null,
      "property2": null
    }
  },
  "publishMode": "additive",
  "sourceMetadata": {
    "property1": null,
    "property2": null
  },
  "buildLog": "string",
  "finalize": {
    "channel": "live"
  },
  "files": [
    {
      "path": "string",
      "size": 0,
      "sha256": "string",
      "contentType": "string",
      "sourceUrl": "http://example.com"
    }
  ],
  "configOnly": true,
  "deletePaths": [],
  "immutableAssetPrefixes": [
    "string"
  ]
}
```

**Responses**

- `200` — Response for status 200
- `201` — Response for status 201
- `default` — Problem details (RFC 9457). Any 4xx/5xx response is one \`application/problem+json\` document.

Response example, 200:

```json
{
  "$schema": "http://example.com",
  "data": {
    "ignoredPaths": [
      "string"
    ],
    "versionId": "string",
    "upload": {
      "id": "string",
      "expiresAt": "2019-08-24T14:15:22Z",
      "summary": {
        "upload": 0,
        "reused": 0,
        "ignored": 0
      },
      "targets": [],
      "bulk": {
        "kind": "zip-cas-v1",
        "method": "PUT",
        "url": "http://example.com",
        "headers": {},
        "maxCompressedBytes": 1,
        "maxExpandedBytes": 1,
        "maxBlobs": 1
      },
      "links": {
        "refresh": "string",
        "resume": "string",
        "finalize": "string"
      },
      "details": {
        "reused": [
          {
            "path": "string",
            "reason": "string"
          }
        ],
        "diagnostics": [
          {
            "code": "string",
            "severity": "info",
            "message": "string",
            "path": "string",
            "provider": "infra",
            "details": {
              "property1": null,
              "property2": null
            },
            "fix": "string",
            "retryable": true
          }
        ]
      }
    }
  }
}
```
