User Migration API public beta

Starting today, both users and organizations now have the ability to request an archive of their repositories, issues, comments, and other data using the Migrations API.

To access this new API during the preview period, you must provide a custom media type in the Accept header:

application/vnd.github.wyandotte-preview+json

During the preview period, we may change aspects of these API methods based on your feedback. If we do, we'll announce the changes here on the developer blog, but we won't provide advance notice.

Requesting a user migration archive

Before you can download an archive of your data, you must first export it. To start a migration, make a POST request to the /user/migrations endpoint, listing the repositories you'd like to include in the archive:

curl -X POST -H "Accept: application/vnd.github.wyandotte-preview+json" -u USERNAME:TOKEN --data '{"repositories":["USERNAME/REPO", "USERNAME/ANOTHER_REPO"]}' https://api.github.com/user/migrations

Checking the status of a migration

After you've started a migration, you can check the status of your archive by making a GET request to the /user/migrations/:migration_id endpoint, using the migration ID provided in the response to your initial request (or as retrieved from GET /user/migrations):

curl -X GET -H "Accept: application/vnd.github.wyandotte-preview+json" -u USERNAME:TOKEN https://api.github.com/user/migrations/:migration_id

Retrieving the archive URL

Once your migration is in the exported state, you can request the URL to your migration archive by making a GET request to the /user/migrations/:migration_id/archive endpoint. This endpoint will return an authenticated URL which you can use to retrieve your archive as a tar.gz file:

curl -X GET -H "Accept: application/vnd.github.wyandotte-preview+json" -u USERNAME:TOKEN https://api.github.com/user/migrations/:migration_id/archive

Deleting an archive

Your migration archive will remain available to download for seven days. If you would like to delete your archive sooner, you can do so by making a DELETE request to the /user/migrations/:migration_id/archive endpoint:

curl -X DELETE -H "Accept: application/vnd.github.wyandotte-preview+json" -u USERNAME:TOKEN https://api.github.com/user/migrations/:migration_id/archive

While the migration will continue to exist, the exported archive and its contents will not.

We hope these endpoints can help users to back up or archive their repository data and better understand what information GitHub stores on their behalf.

If you have any questions or feedback, please get in touch with us.