Edit pending source files - Spacefast Docs
Edit pending source files
Apply complete file replacements and deletions to working files. Keep staging unchanged. Do not commit or deploy.
Endpoint
POST /v1/spaces/{spaceId}/source/workspaces/{workspaceId}/files
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:writespaces:read
Path parameters
spaceIdstring requiredworkspaceIdstring required
Request body
required application/json
expectedRevisioninteger required
Revision from the last workspace response. Read the workspace again after a revision conflict.
min: 0 · max: 9007199254740991
operationIdstring required
Unique ID for this operation. Reuse this ID and the same input after an uncertain response.
min length: 1 · max length: 128
operationsobject[] required
Array of object
One of:
- object
actionstring requiredpathstring required
min length: 1 · max length: 4096contentsstring required
Complete file contents. Omitted files do not change. max length: 1048576encodingstring
Allowed:utf8,base64,hex
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: 9007199254740991statestring required
Allowed:initializing,active,conflicted,closedbaseCommitShastring | 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,undolabelsobject requiredoursstring requiredtheirsstring required
filesobject[] required
Array of objectpathstring requiredresultstring requiredbaseobject requiredsourceCommitShastring requiredcontentstring | any requiredexistsboolean requiredbinaryboolean requiredtruncatedboolean required
oursobject requiredsourceCommitShastring requiredcontentstring | any requiredexistsboolean requiredbinaryboolean requiredtruncatedboolean required
theirsobject requiredsourceCommitShastring requiredcontentstring | any requiredexistsboolean requiredbinaryboolean requiredtruncatedboolean required
Default Problem details (RFC 9457)
Any 4xx/5xx response is one application/problem+json document.
$schemastringtypestring requiredtitlestring requiredstatusinteger requireddetailstring requiredcodestring requiredpointerstringdetailsobjectsuggestionsstring[]nextstring[]requestIdstring required
Try it
Server
Base URL https://api.spacefast.com
Parameters
spaceIdpath*workspaceIdpath*
Request body
Example cURL request
curl -X POST "https://api.spacefast.com/v1/spaces/string/source/workspaces/string/files" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{\n "expectedRevision": 9007199254740991,\n "operationId": "string",\n "operations": [\n {\n "action": "upsert",\n "path": "string",\n "contents": "string",\n "encoding": "utf8"\n }\n ]\n}'
JavaScript fetch request
const response = await fetch("https://api.spacefast.com/v1/spaces/string/source/workspaces/string/files", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
body: "{\n \"expectedRevision\": 9007199254740991,\n \"operationId\": \"string\",\n \"operations\": [\n {\n \"action\": \"upsert\",\n \"path\": \"string\",\n \"contents\": \"string\",\n \"encoding\": \"utf8\"\n }\n ]\n}"
});
Python requests example
import requests
response = requests.post(
"https://api.spacefast.com/v1/spaces/string/source/workspaces/string/files",
headers={
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
data="{\n \"expectedRevision\": 9007199254740991,\n \"operationId\": \"string\",\n \"operations\": [\n {\n \"action\": \"upsert\",\n \"path\": \"string\",\n \"contents\": \"string\",\n \"encoding\": \"utf8\"\n }\n ]\n}",
)
Response 200 default example
{
"$schema": "http://example.com",
"data": {
"workspace": {
"id": "string",
"spaceId": "string",
"repositoryId": "string",
"targetBranch": "string",
"name": "string",
"revision": 9007199254740991,
"state": "initializing",
"baseCommitSha": "string",
"indexCommitSha": "string",
"workingCommitSha": "string",
"headCommitSha": "string",
"originalUploadVersionId": "string",
"hasStagedChanges": true,
"hasUnstagedChanges": true,
"hasPendingChanges": true,
"needsSync": true,
"pendingOperationId": "string",
"autoDeploy": true,
"createdAt": "string",
"updatedAt": "string"
},
"commit": {
"sourceCommitSha": "string",
"parentSourceCommitSha": "string",
"message": "string",
"autoDeploy": true
},
"conflicts": {
"phase": "staged",
"labels": {
"ours": "string",
"theirs": "string"
},
"files": [
{
"path": "string",
"result": "string",
"base": {
"sourceCommitSha": "string",
"content": "string",
"exists": true,
"binary": true,
"truncated": true
},
"ours": {
"sourceCommitSha": "string",
"content": "string",
"exists": true,
"binary": true,
"truncated": true
},
"theirs": {
"sourceCommitSha": "string",
"content": "string",
"exists": true,
"binary": true,
"truncated": true
}
}
]
}
}
}
Error response example
{
"$schema": "http://example.com",
"type": "string",
"title": "string",
"status": -9007199254740991,
"detail": "string",
"code": "string",
"pointer": "string",
"details": {
"property1": null,
"property2": null
},
"suggestions": [
"string"
],
"next": [
"string"
],
"requestId": "string"
}