Provisionally create a new machine definition version.

POST /machines/{machineSlug}/v

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

  • machineSlug string Required

    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?

Body

Request to provisionally create a machine definition version.

object object

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 the machineDefinitionVersionId returned from this operation.

    Hide response attributes Show response attributes object
  • The request was unauthorized.

    Hide response attributes Show response attributes object
    • error string

      A description of the error.

    • code string

      A code specifying the type of error.

      Values are missing-scope, rejected-by-machine-authorizer, missing-user, or missing-org.

  • The request was malformed.

    Hide response attributes Show response attributes object
    • error string

      A description of the error.

    • code string

      A code specifying the type of error.

      • specify-org indicates that the user has access to multiple orgs and the operation requires specifying an organization. Pass the x-statebacked-org-id header to specify an org ID.
      • invalid-parameter indicates that one of the provided parameters was incorrect

      Values are specify-org or invalid-parameter.

    • The name of the invalid parameter

POST /machines/{machineSlug}/v
curl \
 -X POST https://api.statebacked.dev/machines/my-machine/v \
 -H "Authorization: Bearer $ACCESS_TOKEN" \
 -H "Content-Type: application/json"
Request example
{}
Request examples
{}
Response examples (200)
{
  "machineVersionId": "string",
  "codeUploadUrl": "string",
  "codeUploadFields": {}
}
Response examples (200)
{
  "machineVersionId": "string",
  "codeUploadUrl": "string",
  "codeUploadFields": {}
}
Response examples (403)
{
  "error": "string",
  "code": "missing-scope"
}
Response examples (403)
{
  "error": "string",
  "code": "missing-scope"
}
Response examples (400)
{
  "error": "string",
  "code": "specify-org",
  "parameter": "string"
}
Response examples (400)
{
  "error": "string",
  "code": "specify-org",
  "parameter": "string"
}