Provisionally create a new machine version migration.

POST /machines/{machineSlug}/migrations

This operation returns a code upload URL and fields that can be used to upload the code for the machine version migration.

Once the code is uploaded, call PUT /machines/:machineSlug/migrations/:machineVersionMigrationId with the machineVersionMigrationId returned from this operation to finalize the creation of the machine version migration.

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?

application/json

Body

Request to provisionally create a machine version migration.

Responses

  • 200

    The machine version migration was provisionally created successfully.

    Now, post the code for the machine version migration as follows:

    const { codeUploadFields, codeUploadUrl } = await provisionalVersionMigrationCreationResponse.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 version migration by calling PUT /machines/:machineSlug/migrations/:machineVersionMigrationId with the machineVersionMigrationId returned from this operation.

    Hide response attributes Show response attributes object
  • 403

    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.

  • 400

    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}/migrations
curl \
 -X POST https://api.statebacked.dev/machines/my-machine/migrations \
 -H "Authorization: Bearer $ACCESS_TOKEN" \
 -H "Content-Type: application/json" \
 -d '{"fromMachineVersionId":"string","toMachineVersionId":"string"}'
Request example
{
  "fromMachineVersionId": "string",
  "toMachineVersionId": "string"
}
Response examples (200)
{
  "machineVersionMigrationId": "string",
  "codeUploadUrl": "string",
  "codeUploadFields": {}
}
Response examples (403)
{
  "error": "string",
  "code": "missing-scope"
}
Response examples (400)
{
  "error": "string",
  "code": "specify-org",
  "parameter": "string"
}