Create a durable source workspace - Spacefast Docs
Create a durable source workspace
Create a workspace without a local checkout. Send a unique operationId in the request body. Reuse that operationId and the exact input after an uncertain response. Read the workspace ID from data.workspace.id in the API response. Use this ID as workspaceId in later requests.
The API uses saved source when it exists. Otherwise, omit originalUploadVersionId to import the current eligible direct upload. Send the field only to pin a known eligible upload. If neither source exists, the API creates an empty baseline. This action does not deploy or change the live version.
POST /v1/spaces/{spaceId}/source/workspaces
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:write spaces:read
Path parameters
spaceId string required
Request body
required application/json
operationIdstring required
Unique ID for this operation. Reuse this ID and the same input after an uncertain response. min length 1 · max length 128
namestring
min length 1 · max length 160
targetBranchstring
Existing project branch. Defaults to the production branch. min length 1 · max length 255
originalUploadVersionIdstring
Pinned eligible direct upload to import if this Space has no saved source. Omit to import the current eligible direct upload automatically. Never send a build output version. min length 1 · max length 64
authorobject
Omit to use the registered name and email. If they are incomplete, send the author once when you create the workspace. This affects attribution only.
- name string required
min length 1
- email string
matches ^(?!.)(?!...)([A-Za-z0-9_'+-.][A-Za-z0-9_+-]@[A-Za-z0-9][A-Za-z0-9-]*.[A-Za-z]{2,})$
Responses
200 Response for status 200
$schemastring
Canonical JSON Schema URL for this response body. The server also sends it in the Link: rel="describedby" response header.
dataobject requiredworkspaceobject requiredidstring requiredspaceIdstring requiredrepositoryIdstring requiredtargetBranchstring requirednamestring requiredrevisioninteger required
min 0 · max 9007199254740991
statestring required
Allowed: initializing active conflicted closed
baseCommitShastring | any requiredindexCommitShastring | any requiredworkingCommitShastring | any requiredheadCommitShastring | any requiredoriginalUploadVersionIdstring | any requiredhasStagedChangesboolean requiredhasUnstagedChangesboolean requiredhasPendingChangesboolean requiredneedsSyncboolean requiredpendingOperationIdstring | any requiredautoDeployboolean requiredcreatedAtstring requiredupdatedAtstring required
commitobjectsourceCommitShastring requiredparentSourceCommitShastring requiredmessagestring requiredautoDeployboolean required
conflictsobjectphasestring required
Allowed: staged working undo
labelsobject requiredoursstring required -theirsstring requiredfilesobject[] required
Array of object
pathstring required -resultstring required -baseobject requiredsourceCommitShastring required -contentstring | any required -existsboolean required -binaryboolean required -truncatedboolean requiredoursobject requiredsourceCommitShastring required -contentstring | any required -existsboolean required -binaryboolean required -truncatedboolean requiredtheirsobject requiredsourceCommitShastring required -contentstring | any required -existsboolean required -binaryboolean required -truncatedboolean required
Example requests
cURL Example
curl -X POST "https://api.spacefast.com/v1/spaces/string/source/workspaces" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationId": "string",
"name": "string",
"targetBranch": "string",
"originalUploadVersionId": "string",
"author": {
"name": "string",
"email": "user@example.com"
}
}'
JavaScript Example
const response = await fetch("https://api.spacefast.com/v1/spaces/string/source/workspaces", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
body: "{\n \"operationId\": \"string\",\n \"name\": \"string\",\n \"targetBranch\": \"string\",\n \"originalUploadVersionId\": \"string\",\n \"author\": {\n \"name\": \"string\",\n \"email\": \"user@example.com\"\n }\n}"
});
Python Example
import requests
response = requests.post(
"https://api.spacefast.com/v1/spaces/string/source/workspaces",
headers={
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
data="{\n \"operationId\": \"string\",\n \"name\": \"string\",\n \"targetBranch\": \"string\",\n \"originalUploadVersionId\": \"string\",\n \"author\": {\n \"name\": \"string\",\n \"email\": \"user@example.com\"\n }\n}",
)
Error Responses
Default Problem details (RFC 9457). Any 4xx/5xx response is one application/problem+json document.
$schemastring
Canonical JSON Schema URL for this response body. The server also sends it in the Link: rel="describedby" response header.
typestring required
URL of the documentation page for this error. Derived from code.
titlestring required
Human-readable name of the error type. Derived from code.
statusinteger required
HTTP status of the response, repeated in the body.
min -9007199254740991 · max 9007199254740991
detailstring required
What went wrong in this request.
codestring required
Stable snake_case error code. Match on this, not on detail.
pointerstring
RFC 6901 JSON Pointer to the request field or batch entry that failed, for example /files/37/path. Present on validation failures.
detailsobject
Machine-readable context keyed by the error code.
suggestionsstring[]
Recovery steps safe to show to a person.
nextstring[]
Commands or API requests to run next, usable as written.
requestIdstring required
ID of this request, from the X-Request-Id header or generated. Quote it when contacting support.