> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a Migration

> Initiate a migration of data from an external provider into Telnyx Cloud Storage. Currently, only S3 is supported.



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/storage-data.yml post /storage/migrations
openapi: 3.1.0
info:
  title: Telnyx Storage & Data API
  version: 2.0.0
  description: API for Storage & Data.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /storage/migrations:
    post:
      tags:
        - Data Migration
      summary: Create a Migration
      description: >-
        Initiate a migration of data from an external provider into Telnyx Cloud
        Storage. Currently, only S3 is supported.
      operationId: CreateMigration
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MigrationParams'
      responses:
        '200':
          description: Create Migration Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/MigrationParams'
          headers: {}
        '401':
          description: Unauthorized
        '422':
          description: Unprocessable Entity
      deprecated: false
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Telnyx from 'telnyx';

            const client = new Telnyx({
              apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
            });

            const migration = await client.storage.migrations.create({
              source_id: 'source_id',
              target_bucket_name: 'target_bucket_name',
              target_region: 'target_region',
            });

            console.log(migration.data);
        - lang: Python
          source: |-
            import os
            from telnyx import Telnyx

            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )
            migration = client.storage.migrations.create(
                source_id="source_id",
                target_bucket_name="target_bucket_name",
                target_region="target_region",
            )
            print(migration.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tmigration, err := client.Storage.Migrations.New(context.TODO(), telnyx.StorageMigrationNewParams{\n\t\tMigrationParams: telnyx.MigrationParams{\n\t\t\tSourceID:         \"source_id\",\n\t\t\tTargetBucketName: \"target_bucket_name\",\n\t\t\tTargetRegion:     \"target_region\",\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", migration.Data)\n}\n"
        - lang: Java
          source: >-
            package com.telnyx.sdk.example;


            import com.telnyx.sdk.client.TelnyxClient;

            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;

            import
            com.telnyx.sdk.models.storage.migrations.MigrationCreateResponse;

            import com.telnyx.sdk.models.storage.migrations.MigrationParams;


            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    MigrationParams params = MigrationParams.builder()
                        .sourceId("source_id")
                        .targetBucketName("target_bucket_name")
                        .targetRegion("target_region")
                        .build();
                    MigrationCreateResponse migration = client.storage().migrations().create(params);
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

            telnyx = Telnyx::Client.new(api_key: "My API Key")

            migration = telnyx.storage.migrations.create(
              source_id: "source_id",
              target_bucket_name: "target_bucket_name",
              target_region: "target_region"
            )

            puts(migration)
        - lang: PHP
          source: >-
            <?php


            require_once dirname(__DIR__) . '/vendor/autoload.php';


            use Telnyx\Client;

            use Telnyx\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API
            Key');


            try {
              $migration = $client->storage->migrations->create(
                sourceID: 'source_id',
                targetBucketName: 'target_bucket_name',
                targetRegion: 'target_region',
                refresh: true,
              );

              var_dump($migration);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx storage:migrations create \
              --api-key 'My API Key' \
              --source-id source_id \
              --target-bucket-name target_bucket_name \
              --target-region target_region
components:
  schemas:
    MigrationParams:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the data migration.
          readOnly: true
        source_id:
          type: string
          description: ID of the Migration Source from which to migrate data.
        target_bucket_name:
          type: string
          description: >-
            Bucket name to migrate the data into. Will default to the same name
            as the `source_bucket_name`.
        target_region:
          type: string
          description: Telnyx Cloud Storage region to migrate the data to.
        refresh:
          type: boolean
          description: >-
            If true, will continue to poll the source bucket to ensure new data
            is continually migrated over.
        last_copy:
          type: string
          format: date-time
          description: Time when data migration was last copied from the source.
          readOnly: true
          example: '2020-01-01T00:00:00Z'
        status:
          type: string
          enum:
            - pending
            - checking
            - migrating
            - complete
            - error
            - stopped
          readOnly: true
          description: Status of the migration.
        bytes_to_migrate:
          type: integer
          readOnly: true
          description: Total amount of data found in source bucket to migrate.
        bytes_migrated:
          type: integer
          readOnly: true
          description: Total amount of data that has been succesfully migrated.
        speed:
          type: integer
          readOnly: true
          description: Current speed of the migration.
        eta:
          type: string
          format: date-time
          readOnly: true
          description: Estimated time the migration will complete.
          example: '2020-01-01T00:00:00Z'
        created_at:
          type: string
          format: date-time
          description: Time when data migration was created
          readOnly: true
          example: '2020-01-01T00:00:00Z'
      required:
        - source_id
        - target_bucket_name
        - target_region
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````