Skip to content

Instantly share code, notes, and snippets.

@guiyomh
Created January 24, 2016 18:05
Show Gist options
  • Save guiyomh/4ca5dd8208ebf0dc3ed8 to your computer and use it in GitHub Desktop.
Save guiyomh/4ca5dd8208ebf0dc3ed8 to your computer and use it in GitHub Desktop.
Atlas Hashicorp Creating Boxes with the API

Creating Boxes with the API

This example uses the Boxes API to upload boxes with curl. To get started, you'll need to get an access token.

Then, prepare the upload:

$ curl 'https://atlas.hashicorp.com/api/v1/box/USERNAME/BOX_NAME/version/VERSION/provider/PROVIDER_NAME/upload?access_token=ACCESS_TOKEN'

This should return something like this:

{
  "upload_path": "https://binstore.hashicorp.com/630e42d9-2364-2412-4121-18266770468e",
  "token": "630e42d9-2364-2412-4121-18266770468e"
}

Then, upload your box with the following command, with the filename in this case being foo.box:

$ curl -X PUT --upload-file foo.box https://binstore.hashicorp.com/630e42d9-2364-2412-4121-18266770468e

When the upload finishes, you can verify it worked by making this request and matching the hosted_token it returns to the previously retrieved upload token.

$ curl 'https://atlas.hashicorp.com/api/v1/box/USERNAME/BOX_NAME/version/VERSION_NUMBER/provider/PROVIDER_NAME?access_token=ACCESS_TOKEN'

Your box should then be available for download.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment