Refresh a build's upload target - Spacefast Docs
Refresh a build's upload target
Returns the build with a fresh upload target when the previous one expired before the archive was sent. A target that is still valid comes back unchanged. Only a build still waiting for source qualifies: an upload that already completed fails with 409 build_source_upload_already_completed.
POST/v1/builds/{buildId}/uploads/refresh
Authorization
Authorization Bearer token · header required
`Authorization: Bearer
Path parameters
buildId string required
Responses
200 Response for status 200
$schema string
Canonical JSON Schema URL for this response body. The server also sends it in the `Link: rel="describedby"` response header.
data object required
Properties
build object required
idstring required
Build ID (`bld_` prefix). Opaque, and never derived from a version ID.
spaceIdstring required
Space (`spc_` prefix) the build publishes into.
statusstring required
Where the build is in its lifecycle. `skipped` means the ignored build command decided no build was needed.
Allowed: waiting_for_source, uploading_source, queued, running, succeeded, failed, canceled, skipped
inputobject required
The source a build ran against, with clone URLs and repository connection identifiers removed.
One of:
kindstring required
The build ran against an uploaded source archive.
kindstring required
The build ran against repository source.
refstring
Branch, tag, or ref the build checked out.
commitstring
Commit the ref resolved to. Absent until resolved.
branchstring
Branch the ref belongs to, when it is known.
pullRequestNumberinteger
Pull request the build was raised for. Absent for builds off a plain branch.
max 9007199254740991
sourceobject
Publish provenance as declared when the build started: client, git ref data, and publish message. It is present on running and failed builds, which have no version yet; once a version exists its own `source` is authoritative. Null when nothing was declared.
default: null
Any of:
kindstring required
How this version was produced. `variable_update` and `config_update` mark republishes Spacefast makes on its own when a variable or a setting changed; the rest name what published.
Allowed: direct_upload, cli, dashboard, api, git, import, agent, build, variable_update, config_update
clientstring
Client and version that published, for example `spacefast-cli/1.2.3`.
max length 255
branchstring
Git branch the publish was made from.
max length 255
commitstring
Git commit the publish was made from.
max length 64
messagestring
One-line description of the publish, shown as the version's headline in the dashboard. There is no separate changelog field. The CLI fills it from the git commit message when it can.
max length 2000
dirtyboolean
Whether the working tree had uncommitted changes when the publish was made.
metadataobject
Extra provenance as string pairs, such as a repository, a CI run URL, a workflow, or an actor.
gitobject
Properties
repositorystring | anyrepositoryFullNamestring | anyrepositoryUrlstring | anyrefstring | anybranchstring | anybranchAliasUrlstring | anycommitstring | anycommitShastring | anypullRequestNumbernumber | anysettingsSnapshotobject required
Build settings after saved values and per-run overrides are merged. A build freezes these at creation and runs against them for its whole life.
rootDirectorystring | any required
Directory the build runs in, relative to the source root. Null builds at the root.
default: null
installDirectorystring | any required
Directory dependencies install into, relative to the source root. Null installs in the build directory.
default: null
installCommandstring | any required
Command that installs dependencies. Null lets the build runner pick one.
default: null
buildCommandstring | any required
Command that produces the output. Null lets the build runner pick one.
default: null
outputDirectorystring | any required
Directory the built output is collected from, relative to the build directory. Null lets the build runner detect it.
default: null
ignoredBuildCommandstring | any required
Command run before the build to decide whether the build is needed. Exiting 0 ends the build as `skipped`; any other exit code continues. Null always builds.
default: null
frameworkPresetstring | any required
Framework the source builds with, for example `next` or `vite`. Null lets the build runner detect it.
default: null
platformPresetstring | any required
Platform build convention the source follows, for example `vercel` or `netlify`. Null lets the build runner detect it.
default: null
allowUnsupportedPlatformFeaturesboolean required
Runs the build even when the source declares platform features Spacefast does not support. Defaults to `false`, which refuses those sources.
default: false
timeoutSecondsinteger required
Wall-clock budget for the run, in seconds. Between 60 and 7200; defaults to 900.
min 60 · max 7200 · default: 900
targetobject required
Where a successful build's version goes.
Properties
channelstring | any required
Channel the produced version is promoted to when the build succeeds. Null publishes the version without promoting it.
default: null
previewboolean required
Marks the run as a preview build. The build environment is exported as a preview, and a preview build only supersedes other preview builds on the same branch.
default: false
retryOfBuildIdstring | any required
Build this run retries. Null when it is not a retry.
default: null
producedVersionIdstring | any required
Version (`ver_` prefix) this build minted. Null until a build succeeds and mints one.
reusedVersionIdstring | any required
Version the build reused because the output was unchanged. Null otherwise.
default: null
diagnosticsobject[] required
default: []
Array of object
codestring required
Stable snake_case code for this diagnostic.
severitystring required
How serious the diagnostic is.
Allowed: info, warning, error
messagestring required
What happened, in a sentence a person can act on.
pathstring | any
File or artifact path the diagnostic refers to, with a line number when known, for example `_headers:12`. Absent when it applies to the whole resource.
providerstring | any
Upstream system that raised the diagnostic. Absent when Spacefast raised it.
detailsobject | any
Machine-readable context keyed by the diagnostic code.
fixstring | any
What to change to clear the diagnostic. Absent when there is no known fix.
retryableboolean | any
True when repeating the same operation unchanged can clear the diagnostic.
createdAtstringrequired
ISO 8601 timestamp when the build was created.
startedAtstring| any required
ISO 8601 timestamp when the build runner started the run. Null until it does.
finishedAtstring| any required
ISO 8601 timestamp when the build reached a terminal state. Null while it is still in flight.
uploadobject | any required
default: null
Any of:
bulkobject
One request that carries this page's targets as a single ZIP. Present only when every target on the page is content-addressed. Clients that skip it upload `targets` one by one instead.
kindstring requiredmethodstring requiredurlstring| string required
Runtime endpoint that accepts one ZIP whose entries are named by their digest.
headersobject required
Headers to send verbatim with the ZIP, including the upload authorization.
default: {}
maxCompressedBytesinteger required
Largest ZIP this endpoint accepts, in bytes.
max 9007199254740991
maxExpandedBytesinteger required
Largest total size the ZIP may expand to, in bytes.
max 9007199254740991
maxBlobsinteger required
Most entries one ZIP may carry.
max 9007199254740991
detailsobject
Diagnostics
diagnosticsobject[]
Array of object
codestring required
Stable snake_case code for this diagnostic.
severitystring required
How serious the diagnostic is.
Allowed: info, warning, error
messagestring required
What happened, in a sentence a person can act on.
pathstring | any
File or artifact path the diagnostic refers to, with a line number when known, for example `_headers:12`. Absent when it applies to the whole resource.
providerstring | any
Upstream system that raised the diagnostic. Absent when Spacefast raised it.
detailsobject | any
Machine-readable context keyed by the diagnostic code.
fixstring | any
What to change to clear the diagnostic. Absent when there is no known fix.
retryableboolean | any
True when repeating the same operation unchanged can clear the diagnostic.
Reused
reusedobject[]
Array of object
pathstring requiredreasonstring requiredexpiresAtstringrequired
ISO 8601 timestamp when the authorization in `headers` stops working. Only the credential lapses; the version stays open, and `links.refresh` mints a fresh page with a new one.
IDs
idstring required
Upload session ID (`upl_` prefix).
min length 1
linksobject required
Show propertiesHide properties
refreshstring required
Endpoint that mints a fresh instruction page for whatever the session still needs, with a new authorization. Call it after uploading this page's targets.
resumestringfinalizestring required
Endpoint that commits the version once every declared file has landed.
Summary
summaryobject required
Counts across the whole manifest, not only the targets on this page.
reusedinteger required
Files satisfied by bytes the Space already holds under the same digest.
min 0 · max 9007199254740991
uploadinteger required
Files whose bytes are still needed.
min 0 · max 9007199254740991
Targets
targetsobject[] required
Targets to upload on this page, capped by a per-page limit. Upload these, then call `links.refresh` for whatever the session still needs.
default: []
Array of object
pathstring required
Manifest path whose bytes this target accepts.
methodstring required
Method to send the upload with.
Allowed: PUT, POST
urlstring| string required
Where to send the bytes. Absolute, or relative to the API origin.
headersobject required
Headers to send verbatim, including the upload authorization. Adding or dropping any of them fails the upload.
default: {}
bodyobject
How to fill the request body. Absent means send the local bytes for `path`. `url` means POST this JSON so the runtime fetches the file itself.
Example Requests
curl
curl -X POST "https://api.spacefast.com/v1/builds/string/uploads/refresh" \
-H "Authorization: Bearer YOUR_TOKEN"
JavaScript
const response = await fetch("https://api.spacefast.com/v1/builds/string/uploads/refresh", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_TOKEN"
}
});
Python
import requests
response = requests.post(
"https://api.spacefast.com/v1/builds/string/uploads/refresh",
headers={
"Authorization": "Bearer YOUR_TOKEN"
},
)
Response
{
"$schema": "http://example.com",
"data": {
"build": {
"id": "string",
"spaceId": "string",
"status": "waiting_for_source",
"input": {
"kind": "archive"
},
"source": null,
"settingsSnapshot": {
"rootDirectory": null,
"installDirectory": null,
"installCommand": null,
"buildCommand": null,
"outputDirectory": null,
"ignoredBuildCommand": null,
"frameworkPreset": null,
"platformPreset": null,
"allowUnsupportedPlatformFeatures": false,
"timeoutSeconds": 900
},
"target": {
"channel": null,
"preview": false
},
"retryOfBuildId": null,
"producedVersionId": "string",
"reusedVersionId": null,
"diagnostics": [],
"createdAt": "2019-08-24T14:15:22Z",
"startedAt": "2019-08-24T14:15:22Z",
"finishedAt": "2019-08-24T14:15:22Z"
},
"upload": null
}
}
{
"$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"
}