Create a build - Spacefast Docs

Create a build

Creates a build for the Space and returns it, with an upload target when the input needs one. An archive input starts the build waiting for source and hands back the target to send the archive to; a repository input resolves the saved connection and queues the build straight away. Naming a managed source instead of an input builds the Space’s configured WordPress source from its connected production repository, at the saved settings and the live channel, and requires an Idempotency-Key header: without one the call fails with 422 idempotency_key_required. Repeating an Idempotency-Key returns the build that key already created with 200 rather than 201, and reusing it for a different body fails with 409 idempotency_key_reused. A successful build mints a version through the same publish path as any other publish.

POST /v1/spaces/{spaceId}/builds

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).

Path parameters

Header parameters

Client-generated key, up to 255 characters, that makes this write safe to retry. The first request with a key stores its outcome, scoped to the tenant, credential, method, and path. A retry with the same key and body replays the stored response with Idempotency-Replayed: true. A different body with the same key fails with 409 idempotency_key_reused. A retry while the first request is still running fails with 409 idempotency_conflict_in_progress. Keys are kept for 24 hours.

max length 255

Request body

required application/json

Either a build described with input, or a managed source that decides what to build.

One of:

Show properties

Array of object

Any of:


input: object required

What a new build runs against.

One of:

object

Show properties

rootDirectory, installDirectory, installCommand, buildCommand, outputDirectory, ignoredBuildCommand,

frameworkPreset, platformPreset

allowUnsupportedPlatformFeatures: boolean

timeoutSeconds: integer min 60 · max 7200


target: object required

Where a successful build's version goes.

Array of object


createdAt, startedAt, finishedAt


upload: object | any required

responses

200 Response for status 200

Try it

cURL Example

curl -X POST "https://api.spacefast.com/v1/spaces/string/builds" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "source": "wordpress",
  "sourceUrl": "http://example.com"
}'

JavaScript Example

const response = await fetch("https://api.spacefast.com/v1/spaces/string/builds", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json"
  },
  body: "{\n  \"source\": \"wordpress\",\n  \"sourceUrl\": \"http://example.com\"\n}"
});

Python Example

import requests

response = requests.post(
    "https://api.spacefast.com/v1/spaces/string/builds",
    headers={
        "Authorization": "Bearer YOUR_TOKEN",
        "Content-Type": "application/json"
    },
    data="{\n  \"source\": \"wordpress\",\n  \"sourceUrl\": \"http://example.com\"\n}",
)