# 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. ## Servers - Production server: https://api.statebacked.dev (Production server) ## Authentication methods - Bearer auth ## Parameters #### Path parameters - **machineSlug** (string) The slug/name for the machine definition this version is related to. #### Query parameters - **gzip** (boolean) Will the code be uploaded gzipped? ## Body parameters Content-type: Request to provisionally create a machine version migration. - **fromMachineVersionId** (string) The ID of a machine definition version. - **toMachineVersionId** (string) The ID of a machine definition version. ## 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. #### Body Parameters: (object) - **machineVersionMigrationId** (string) The signed machine version migration ID. - **codeUploadUrl** (string) The URL to upload the machine definition version code to. - **codeUploadFields** (object) The fields that must be included as form data in the upload request. ### 403: The request was unauthorized. #### Body Parameters: (object) - **error** (string) A description of the error. - **code** (string) A code specifying the type of error. ### 400: The request was malformed. #### Body Parameters: (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 - **parameter** (string) The name of the invalid parameter [Powered by Bump.sh](https://bump.sh)