Save staged source as one commit - Spacefast Docs
Save staged source as one commit
Commit only the staged tree. Keep other pending changes. Reject a moved project branch. Configured automatic deployment may start a build.
POST /v1/spaces/{spaceId}/source/workspaces/{workspaceId}/commit
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
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
messagestring required- min length 1 · max length 4096
authorobject- Omit to reuse the author stored when the workspace was created.
namestring required - min length 1emailstringrequired - matches
^(?!\.)(?!.*\.\.)([A-Za-z0-9\'+\-\.]*[A-Za-z0-9\_+-]@[A-Za-z0-9][A-Za-z0-9\-]*\.[A-Za-z]{2,})$
- matches
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.
- Canonical JSON Schema URL for this response body. The server also sends it in the
dataobject requiredworkspaceobject requiredidstring required -spaceIdstring required -repositoryIdstring required -targetBranchstring required -namestring required -revisioninteger required - min 0 · max 9007199254740991 -statestring required - Allowed:initializingactiveconflictedclosed-baseCommitShastring | any required -indexCommitShastring | any required -workingCommitShastring | any required -headCommitShastring | any required -originalUploadVersionIdstring | any required -hasStagedChangesboolean required -hasUnstagedChangesboolean required -hasPendingChangesboolean required -needsSyncboolean required -pendingOperationIdstring | any required -autoDeployboolean required -createdAtstring required -updatedAtstring requiredcommitobjectsourceCommitShastring required - matches^[a-f0-9]{40}$-parentSourceCommitShastring required - matches^[a-f0-9]{40}$-messagestring required -autoDeployboolean requiredconflictsobjectphasestring required - Allowed:stagedworkingundo-labelsobject requiredoursstring required -theirsstring required -filesobject[] required - Array ofobjectpathstring required -resultstring required -baseobject requiredsourceCommitShastring required - matches^[a-f0-9]{40}$-contentstring | any required -existsboolean required -binaryboolean required -truncatedboolean required -oursobject requiredsourceCommitShastring required - matches^[a-f0-9]{40}$-contentstring | any required -existsboolean required -binaryboolean required -truncatedboolean required -theirsobject requiredsourceCommitShastring required - matches^[a-f0-9]{40}$-contentstring | any required -existsboolean required -binaryboolean required -truncatedboolean required
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.
- Canonical JSON Schema URL for this response body. The server also sends it in the
typestring required- URL of the documentation page for this error. Derived from
code.
- URL of the documentation page for this error. Derived from
titlestring required- Human-readable name of the error type. Derived from
code.
- Human-readable name of the error type. Derived from
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.
- Stable snake_case error code. Match on this, not on
pointerstring- RFC 6901 JSON Pointer to the request field or batch entry that failed, for example
/files/37/path. Present on validation failures.
- RFC 6901 JSON Pointer to the request field or batch entry that failed, for example
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-Idheader or generated. Quote it when contacting support.
- ID of this request, from the
Try it
Server
Base URL https://api.spacefast.com
Custom base URL Overrides the selected server when set.
Authorization
Bearer token Remember on this device
Include my values in samples
Parameters
spaceIdpath*workspaceIdpath*
Body application/json
Request body
Send Request
cURL
curl -X POST "https://api.spacefast.com/v1/spaces/string/source/workspaces/string/commit" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{\
"expectedRevision": 9007199254740991,\
"operationId": "string",\
"message": "string",\
"author": {\
"name": "string",\
"email": "user@example.com"\
}\
}'
JavaScript
const response = await fetch("https://api.spacefast.com/v1/spaces/string/source/workspaces/string/commit", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
body: "{\
\"expectedRevision\": 9007199254740991,\
\"operationId\": \"string\",\
\"message\": \"string\",\
\"author\": {\
\"name\": \"string\",\
\"email\": \"user@example.com\"\
}\
}"
});
Python
import requests
response = requests.post(
"https://api.spacefast.com/v1/spaces/string/source/workspaces/string/commit",
headers={
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
data="{\
\"expectedRevision\": 9007199254740991,\
\"operationId\": \"string\",\
\"message\": \"string\",\
\"author\": {\
\"name\": \"string\",\
\"email\": \"user@example.com\"\
}\
}",
)
Response 200 default
{
"$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
{
"$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"
}