Who are the three (different?) orgs/users in `installation` web hook payload?


#1

The payload of an installation event hook looks like:

{
  "action": "created",
  "installation": {
    "id": 73319,
    "account": {
      "login": "userhandle",
      "id": <user_id>,
      ...
    },
    ...
    "app_id": <app_id>,
    "target_id": <target_id_which_for_me_is_same_as_user_id>,
    "target_type": "User",
      ...
  },
  ...
  "sender": {
    "login": "userhandle",
    "id": <user_id>,
    ...
  }
}

So I don’t know who is who here; because I’ve only got two GH accounts and there are three IDs here. My GUESS:

  • ['installation']['account']['id'] is the account (org/user) on which the app was installed
  • ['installation']['target_id'] is redundant information (the target account on which to install the app) and therefore always equal to ['installation']['account']['id']
  • ['sender']['id'] is the user who installed the app

But this doesn’t seem quite right (why would GH duplicate the target info? Target terminology also suggests that the app isn’t installed yet, but you only get the hook on installation).

Please can anyone clarify:

  • the roles of the three (possibly different) users/orgs who are identified in this payload please?
  • what the “target” terminology refers to in the context of an installation payload?

Thanks for any help!

Tom


#2

@thclark these are good questions!

The hook triggers on both install and uninstall, and the sender is, indeed, the user who triggered the action. This is typically useful only in the context of installing the app on an organization where any admin could trigger the action. For a user account only the user in question can trigger the action.

The target is the account on which the installation is being installed/uninstalled, and could be a user or an organization.

The account is the same as the target. I don’t know why this was done in this way. The account contains more information than the target does. You’re right that it is duplicated, though, because account.type will be the same as target_type.


#3

Great, thanks @kytrinx - that’s good news as my afternoon of coding wasn’t wasted :slight_smile: