{"action":"created","comment":{"url":"https://api.github.com/repos/supportkit/supportkit-docs/pulls/comments/41435230","id":41435230,"diff_hunk":"@@ -59,157 +81,220 @@ The JWT header must contain the key id (`kid`) of the secret key that is used to\n }\n ```\n \n+The JWT header must contain the key id (`kid`) of the secret key that is used to sign it. The algorithm (`alg`) used to sign the JWT can be anything supported by the [jsonwebtoken npm module v5.0.4](https://www.npmjs.com/package/jsonwebtoken#algorithms-supported). Unsigned JWTs are not accepted.\n+\n+> JWT body with `appUser` scope:\n+\n+```json\n+{\n+    \"scope\": \"appUser\",\n+    \"userId\": \"bob@example.com\" \n+}\n+```\n+\n+> JWT body with `app` scope:\n+\n+```json\n+{\n+    \"scope\": \"app\"\n+}\n+```\n+\n ### Scope\n \n-The JWT body must include a scope parameter that determines the level of access of the bearer. There are two scopes, `appUser` and `app`.\n+The JWT body must specify the caller's scope of access. There are two levels of scope:\n+\n+1. The `appUser` scope grants access to an individual app user's data and conversation history, but nothing else. It is used when issuing tokens to individual users. A JWT with `appUser` scope must also specify a `userId` which uniquely identifies the `appUser` being accessed. [Node.js code sample](https://gist.github.com/alavers/8f07b03895333d83b454)\n \n-#### appUser scope\n+1. The `app` scope grants access to all users and conversations within a given SupportKit app. The `app` scope is reserved for server-to-server scenarios, the creation of webhooks for example. [Node.js code sample](https://gist.github.com/alavers/d9af102ca4cefac1a7e5)\n \n-The `appUser` scope grants access to an individual app user's data and conversation, but nothing else. It is used when issuing tokens to individual users. A JWT with `appUser` scope must also specify a `userId`. The `userId` field effectively limits the scope of what a client can access using a given JWT.\n+| API                       | Accepted JWT Scopes |\n+|---------------------------|---------------------|\n+| [/api/appboot](#app-boot) | appUser             |\n+| [/api/appuser](#app-user) | appUser, app        |\n+| [/api/webhook](#webhook)  | app                 |\n \n-[Node.js appUser JWT code sample](https://gist.github.com/alavers/8f07b03895333d83b454)\n+# Webhooks\n \n-> Example JWT body for accessing app user data:\n+> Webhook example payload:\n \n ```json\n {\n-    \"scope\": \"appUser\",\n-    \"userId\": \"bob@example.com\" \n+    \"event\": \"message\",\n+    \"items\":[{\n+        \"_id\": \"55c8c1498590aa1900b9b9b1\",\n+        \"authorId\": \"c7f6e6d6c3a637261bd9656f\",\n+        \"name\": \"Steve\",\n+        \"text\": \"Hi! Do you have time to chat?\",\n+        \"received\": 1439220041.586\n+    }],\n+    \"appUserId\": \"c7f6e6d6c3a637261bd9656f\"\n }\n ```\n \n-#### app scope\n+Webhooks are a fantastic way to extend SupportKit platform beyond the built-in featuere set. You can use webhooks to build your own SupportKit chat clients or to integrate more deeply with your favorite CRM.","path":"source/rest/index.md","position":139,"original_position":139,"commit_id":"b7a2accbe1602d4ca4d0b0cba3301891171cf971","original_commit_id":"b7a2accbe1602d4ca4d0b0cba3301891171cf971","user":{"login":"alavers","id":2432382,"avatar_url":"https://avatars.githubusercontent.com/u/2432382?v=3","gravatar_id":"","url":"https://api.github.com/users/alavers","html_url":"https://github.com/alavers","followers_url":"https://api.github.com/users/alavers/followers","following_url":"https://api.github.com/users/alavers/following{/other_user}","gists_url":"https://api.github.com/users/alavers/gists{/gist_id}","starred_url":"https://api.github.com/users/alavers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alavers/subscriptions","organizations_url":"https://api.github.com/users/alavers/orgs","repos_url":"https://api.github.com/users/alavers/repos","events_url":"https://api.github.com/users/alavers/events{/privacy}","received_events_url":"https://api.github.com/users/alavers/received_events","type":"User","site_admin":false},"body":":white_check_mark: ","created_at":"2015-10-07T19:33:35Z","updated_at":"2015-10-07T19:33:35Z","html_url":"https://github.com/supportkit/supportkit-docs/pull/18#discussion_r41435230","pull_request_url":"https://api.github.com/repos/supportkit/supportkit-docs/pulls/18","_links":{"self":{"href":"https://api.github.com/repos/supportkit/supportkit-docs/pulls/comments/41435230"},"html":{"href":"https://github.com/supportkit/supportkit-docs/pull/18#discussion_r41435230"},"pull_request":{"href":"https://api.github.com/repos/supportkit/supportkit-docs/pulls/18"}}},"pull_request":{"url":"https://api.github.com/repos/supportkit/supportkit-docs/pulls/18","id":46973262,"html_url":"https://github.com/supportkit/supportkit-docs/pull/18","diff_url":"https://github.com/supportkit/supportkit-docs/pull/18.diff","patch_url":"https://github.com/supportkit/supportkit-docs/pull/18.patch","issue_url":"https://api.github.com/repos/supportkit/supportkit-docs/issues/18","number":18,"state":"open","locked":false,"title":"Doc bugs","user":{"login":"alavers","id":2432382,"avatar_url":"https://avatars.githubusercontent.com/u/2432382?v=3","gravatar_id":"","url":"https://api.github.com/users/alavers","html_url":"https://github.com/alavers","followers_url":"https://api.github.com/users/alavers/followers","following_url":"https://api.github.com/users/alavers/following{/other_user}","gists_url":"https://api.github.com/users/alavers/gists{/gist_id}","starred_url":"https://api.github.com/users/alavers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alavers/subscriptions","organizations_url":"https://api.github.com/users/alavers/orgs","repos_url":"https://api.github.com/users/alavers/repos","events_url":"https://api.github.com/users/alavers/events{/privacy}","received_events_url":"https://api.github.com/users/alavers/received_events","type":"User","site_admin":false},"body":"@jpjoyal @mspensieri ","created_at":"2015-10-06T23:57:44Z","updated_at":"2015-10-07T19:33:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"540d3bcf6bbab4d6b4aab846cae71b1d1c953dfb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/supportkit/supportkit-docs/pulls/18/commits","review_comments_url":"https://api.github.com/repos/supportkit/supportkit-docs/pulls/18/comments","review_comment_url":"https://api.github.com/repos/supportkit/supportkit-docs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/supportkit/supportkit-docs/issues/18/comments","statuses_url":"https://api.github.com/repos/supportkit/supportkit-docs/statuses/b7a2accbe1602d4ca4d0b0cba3301891171cf971","head":{"label":"supportkit:doc-bugs","ref":"doc-bugs","sha":"b7a2accbe1602d4ca4d0b0cba3301891171cf971","user":{"login":"supportkit","id":12100406,"avatar_url":"https://avatars.githubusercontent.com/u/12100406?v=3","gravatar_id":"","url":"https://api.github.com/users/supportkit","html_url":"https://github.com/supportkit","followers_url":"https://api.github.com/users/supportkit/followers","following_url":"https://api.github.com/users/supportkit/following{/other_user}","gists_url":"https://api.github.com/users/supportkit/gists{/gist_id}","starred_url":"https://api.github.com/users/supportkit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/supportkit/subscriptions","organizations_url":"https://api.github.com/users/supportkit/orgs","repos_url":"https://api.github.com/users/supportkit/repos","events_url":"https://api.github.com/users/supportkit/events{/privacy}","received_events_url":"https://api.github.com/users/supportkit/received_events","type":"Organization","site_admin":false},"repo":{"id":39525331,"name":"supportkit-docs","full_name":"supportkit/supportkit-docs","owner":{"login":"supportkit","id":12100406,"avatar_url":"https://avatars.githubusercontent.com/u/12100406?v=3","gravatar_id":"","url":"https://api.github.com/users/supportkit","html_url":"https://github.com/supportkit","followers_url":"https://api.github.com/users/supportkit/followers","following_url":"https://api.github.com/users/supportkit/following{/other_user}","gists_url":"https://api.github.com/users/supportkit/gists{/gist_id}","starred_url":"https://api.github.com/users/supportkit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/supportkit/subscriptions","organizations_url":"https://api.github.com/users/supportkit/orgs","repos_url":"https://api.github.com/users/supportkit/repos","events_url":"https://api.github.com/users/supportkit/events{/privacy}","received_events_url":"https://api.github.com/users/supportkit/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/supportkit/supportkit-docs","description":"Docs living at docs.supportkit.io","fork":false,"url":"https://api.github.com/repos/supportkit/supportkit-docs","forks_url":"https://api.github.com/repos/supportkit/supportkit-docs/forks","keys_url":"https://api.github.com/repos/supportkit/supportkit-docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/supportkit/supportkit-docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/supportkit/supportkit-docs/teams","hooks_url":"https://api.github.com/repos/supportkit/supportkit-docs/hooks","issue_events_url":"https://api.github.com/repos/supportkit/supportkit-docs/issues/events{/number}","events_url":"https://api.github.com/repos/supportkit/supportkit-docs/events","assignees_url":"https://api.github.com/repos/supportkit/supportkit-docs/assignees{/user}","branches_url":"https://api.github.com/repos/supportkit/supportkit-docs/branches{/branch}","tags_url":"https://api.github.com/repos/supportkit/supportkit-docs/tags","blobs_url":"https://api.github.com/repos/supportkit/supportkit-docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/supportkit/supportkit-docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/supportkit/supportkit-docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/supportkit/supportkit-docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/supportkit/supportkit-docs/statuses/{sha}","languages_url":"https://api.github.com/repos/supportkit/supportkit-docs/languages","stargazers_url":"https://api.github.com/repos/supportkit/supportkit-docs/stargazers","contributors_url":"https://api.github.com/repos/supportkit/supportkit-docs/contributors","subscribers_url":"https://api.github.com/repos/supportkit/supportkit-docs/subscribers","subscription_url":"https://api.github.com/repos/supportkit/supportkit-docs/subscription","commits_url":"https://api.github.com/repos/supportkit/supportkit-docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/supportkit/supportkit-docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/supportkit/supportkit-docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/supportkit/supportkit-docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/supportkit/supportkit-docs/contents/{+path}","compare_url":"https://api.github.com/repos/supportkit/supportkit-docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/supportkit/supportkit-docs/merges","archive_url":"https://api.github.com/repos/supportkit/supportkit-docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/supportkit/supportkit-docs/downloads","issues_url":"https://api.github.com/repos/supportkit/supportkit-docs/issues{/number}","pulls_url":"https://api.github.com/repos/supportkit/supportkit-docs/pulls{/number}","milestones_url":"https://api.github.com/repos/supportkit/supportkit-docs/milestones{/number}","notifications_url":"https://api.github.com/repos/supportkit/supportkit-docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/supportkit/supportkit-docs/labels{/name}","releases_url":"https://api.github.com/repos/supportkit/supportkit-docs/releases{/id}","created_at":"2015-07-22T19:13:33Z","updated_at":"2015-09-16T15:25:32Z","pushed_at":"2015-10-07T02:44:34Z","git_url":"git://github.com/supportkit/supportkit-docs.git","ssh_url":"git@github.com:supportkit/supportkit-docs.git","clone_url":"https://github.com/supportkit/supportkit-docs.git","svn_url":"https://github.com/supportkit/supportkit-docs","homepage":"http://docs.supportkit.io","size":129704,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"integration"}},"base":{"label":"supportkit:REST-toggle","ref":"REST-toggle","sha":"2687927354940858c6a5ec392a2387b9a2a6a876","user":{"login":"supportkit","id":12100406,"avatar_url":"https://avatars.githubusercontent.com/u/12100406?v=3","gravatar_id":"","url":"https://api.github.com/users/supportkit","html_url":"https://github.com/supportkit","followers_url":"https://api.github.com/users/supportkit/followers","following_url":"https://api.github.com/users/supportkit/following{/other_user}","gists_url":"https://api.github.com/users/supportkit/gists{/gist_id}","starred_url":"https://api.github.com/users/supportkit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/supportkit/subscriptions","organizations_url":"https://api.github.com/users/supportkit/orgs","repos_url":"https://api.github.com/users/supportkit/repos","events_url":"https://api.github.com/users/supportkit/events{/privacy}","received_events_url":"https://api.github.com/users/supportkit/received_events","type":"Organization","site_admin":false},"repo":{"id":39525331,"name":"supportkit-docs","full_name":"supportkit/supportkit-docs","owner":{"login":"supportkit","id":12100406,"avatar_url":"https://avatars.githubusercontent.com/u/12100406?v=3","gravatar_id":"","url":"https://api.github.com/users/supportkit","html_url":"https://github.com/supportkit","followers_url":"https://api.github.com/users/supportkit/followers","following_url":"https://api.github.com/users/supportkit/following{/other_user}","gists_url":"https://api.github.com/users/supportkit/gists{/gist_id}","starred_url":"https://api.github.com/users/supportkit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/supportkit/subscriptions","organizations_url":"https://api.github.com/users/supportkit/orgs","repos_url":"https://api.github.com/users/supportkit/repos","events_url":"https://api.github.com/users/supportkit/events{/privacy}","received_events_url":"https://api.github.com/users/supportkit/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/supportkit/supportkit-docs","description":"Docs living at docs.supportkit.io","fork":false,"url":"https://api.github.com/repos/supportkit/supportkit-docs","forks_url":"https://api.github.com/repos/supportkit/supportkit-docs/forks","keys_url":"https://api.github.com/repos/supportkit/supportkit-docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/supportkit/supportkit-docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/supportkit/supportkit-docs/teams","hooks_url":"https://api.github.com/repos/supportkit/supportkit-docs/hooks","issue_events_url":"https://api.github.com/repos/supportkit/supportkit-docs/issues/events{/number}","events_url":"https://api.github.com/repos/supportkit/supportkit-docs/events","assignees_url":"https://api.github.com/repos/supportkit/supportkit-docs/assignees{/user}","branches_url":"https://api.github.com/repos/supportkit/supportkit-docs/branches{/branch}","tags_url":"https://api.github.com/repos/supportkit/supportkit-docs/tags","blobs_url":"https://api.github.com/repos/supportkit/supportkit-docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/supportkit/supportkit-docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/supportkit/supportkit-docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/supportkit/supportkit-docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/supportkit/supportkit-docs/statuses/{sha}","languages_url":"https://api.github.com/repos/supportkit/supportkit-docs/languages","stargazers_url":"https://api.github.com/repos/supportkit/supportkit-docs/stargazers","contributors_url":"https://api.github.com/repos/supportkit/supportkit-docs/contributors","subscribers_url":"https://api.github.com/repos/supportkit/supportkit-docs/subscribers","subscription_url":"https://api.github.com/repos/supportkit/supportkit-docs/subscription","commits_url":"https://api.github.com/repos/supportkit/supportkit-docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/supportkit/supportkit-docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/supportkit/supportkit-docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/supportkit/supportkit-docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/supportkit/supportkit-docs/contents/{+path}","compare_url":"https://api.github.com/repos/supportkit/supportkit-docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/supportkit/supportkit-docs/merges","archive_url":"https://api.github.com/repos/supportkit/supportkit-docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/supportkit/supportkit-docs/downloads","issues_url":"https://api.github.com/repos/supportkit/supportkit-docs/issues{/number}","pulls_url":"https://api.github.com/repos/supportkit/supportkit-docs/pulls{/number}","milestones_url":"https://api.github.com/repos/supportkit/supportkit-docs/milestones{/number}","notifications_url":"https://api.github.com/repos/supportkit/supportkit-docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/supportkit/supportkit-docs/labels{/name}","releases_url":"https://api.github.com/repos/supportkit/supportkit-docs/releases{/id}","created_at":"2015-07-22T19:13:33Z","updated_at":"2015-09-16T15:25:32Z","pushed_at":"2015-10-07T02:44:34Z","git_url":"git://github.com/supportkit/supportkit-docs.git","ssh_url":"git@github.com:supportkit/supportkit-docs.git","clone_url":"https://github.com/supportkit/supportkit-docs.git","svn_url":"https://github.com/supportkit/supportkit-docs","homepage":"http://docs.supportkit.io","size":129704,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"integration"}},"_links":{"self":{"href":"https://api.github.com/repos/supportkit/supportkit-docs/pulls/18"},"html":{"href":"https://github.com/supportkit/supportkit-docs/pull/18"},"issue":{"href":"https://api.github.com/repos/supportkit/supportkit-docs/issues/18"},"comments":{"href":"https://api.github.com/repos/supportkit/supportkit-docs/issues/18/comments"},"review_comments":{"href":"https://api.github.com/repos/supportkit/supportkit-docs/pulls/18/comments"},"review_comment":{"href":"https://api.github.com/repos/supportkit/supportkit-docs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/supportkit/supportkit-docs/pulls/18/commits"},"statuses":{"href":"https://api.github.com/repos/supportkit/supportkit-docs/statuses/b7a2accbe1602d4ca4d0b0cba3301891171cf971"}}}}