Skip to content

Instantly share code, notes, and snippets.

Last active Jan 31, 2019
What would you like to do?
Heroku API - Grab ID


  • brew install jq (jq is like sed for json)
  • put this in your .bashrc or .zshrc
  • pbcopy is an OSX thing (I'm sure there's a linux/windows way to do this too?)
  • You will need the heroku cli api plugin:


See the notes in the code

# grabid
# grab id from the heroku api endpoint
# and then copy it into clipboard
# grabid /addon-services/deployhooks
# grabid /apps/powerful-hamlet-24622
function grabid() {
thingId=$(heroku api get $1 | jq '.id' -r)
echo "endpoint: $1"
echo "id: $thingId"
printf $thingId | pbcopy # printf so no new line
echo 'id copied to clipboard'

Other ways to do the same thing (without the copy into clipboard):

  • heroku sudo api get /apps/some-app-name | jq '.id' (sudo is herokai only)
  • heroku apps:info --json -a some-app-name | jq

This comment has been minimized.

Copy link

@joshwlewis joshwlewis commented Jun 23, 2017


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