Copying Slugs with the Platform API

Last Updated: 10 September 2014

api platform-api slug

This article describes how a slug from one app can be used to create a release on another app. Imagine that you have pushed code to a staging app, the code has been tested and you are now ready to release to production. Instead of pushing to the production app and waiting for the code to build again, you can simply copy the slug from the staging app to the production app.

A Heroku user can only manipulate slugs that were created on apps that they have access to. If you try to create a release using a slug that was created on an app that you do not have access to, you will get a HTTP 403 Forbidden status. See the Dev Center section on collaboration for details.

First, list releases on the staging app to get the id of the slug to release on the production app:

$ curl -H "Accept: application/vnd.heroku+json; version=3" -n \
"slug":{ "id":"ff40c84f-a538-4b65-a838-88fdd5245f4b" }

Now, create a new release on the production app using the slug from the staging app:

$ curl -X POST -H "Accept: application/vnd.heroku+json; version=3" -n \
-H "Content-Type: application/json" \
-d '{"slug": "ff40c84f-a538-4b65-a838-88fdd5245f4b"}' \

That’s it! The new code is now running on the example-app-production app.

Note that copying slugs between apps is already possible using the beta Pipelines plugin, and Heroku Fork. The release endpoint exposes the primitives necessary for third-party API developers to build services offering similar functionality.