Provisionally create a new machine definition version.
This operation returns a code upload URL and fields that can be used to upload the code for the machine definition version.
Once the code is uploaded, call PUT /machines/:machineSlug/v/:machineDefinitionVersionId
with the machineDefinitionVersionId
returned from this operation to
finalize the creation of the machine definition version.
Path parameters
-
The slug/name for the machine definition this version is related to.
Minimum length is
1
. Format should match the following pattern:^[a-zA-Z0-9_-]{1,128}$
.
Query parameters
-
gzip boolean
Will the code be uploaded gzipped?
Responses
-
The machine definition version was provisionally created successfully.
Now, post the code for the machine definition version as follows:
const { codeUploadFields, codeUploadUrl } = await provisionalVersionCreationResponse.json(); const uploadForm = new FormData(); for (const [key, value] of Object.entries(codeUploadFields)) { uploadForm.append(key, value as string); } uploadForm.set("content-type", "application/javascript"); uploadForm.append( "file", new Blob(["javascript-code-here"], { type: "application/javascript", }), "your-file-name.js", ); const uploadRes = await fetch( codeUploadUrl, { method: "POST", body: uploadForm, }, );
And then finalize the creation of the machine definition version by calling
PUT /machines/:machineSlug/v/:machineDefinitionVersionId
with themachineDefinitionVersionId
returned from this operation. -
The request was unauthorized.
-
The request was malformed.
curl \
-X POST https://api.statebacked.dev/machines/my-machine/v \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json"
{}
{}
{
"machineVersionId": "string",
"codeUploadUrl": "string",
"codeUploadFields": {}
}
{
"machineVersionId": "string",
"codeUploadUrl": "string",
"codeUploadFields": {
"Additional properties:": "string"
}
}
{
"error": "string",
"code": "missing-scope"
}
{
"error": "string",
"code": "missing-scope"
}
{
"error": "string",
"code": "specify-org",
"parameter": "string"
}
{
"error": "string",
"code": "specify-org",
"parameter": "string"
}