Skip to content

Latest commit

 

History

History
107 lines (78 loc) · 3.92 KB

webhooks.md

File metadata and controls

107 lines (78 loc) · 3.92 KB

Webhooks

This tutorial shows how to register and unregister webhooks. Webhook change notifications enable applications to be informed when data within an ORCID record changes. (Note: Actual data exchange is based on visibility levels set by the ORCID iD holder and permissions the individual has granted to the client.)

This feature is only available on the Member API and only for Premium ORCID Members, it can be used on sandbox or production.

Generate a webhooks access token

This process is completed using the 2 step token exchange. A single token can be used to register webhooks for multiple records.

Parameter Value
Base URL https://sandbox.orcid.org/oauth/token
Client_id Your client ID
Client_secret Your client secret
Grant_type client_credentials
Scope /webhook

Curl example:

curl -i -L -H "Accept: application/json"
  -d "client_id=APP-NPXKK6HFN6TJ4YYI"
  -d "client_secret=060c36f2-cce2-4f74-bde0-a17d8bb30a97"
  -d "scope=/webhook"
  -d "grant_type=client_credentials"
  "https://sandbox.orcid.org/oauth/token"

Example response:

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Cache-Control: no-store
Content-Type: application/json;charset=UTF-8
Date: Fri, 05 Apr 2013 13:05:01 GMT

{"access_token":"5eb23750-1e19-47a3-b6f6-26635c34e8ee",
  "token_type":"bearer",
  "refresh_token":"c7d3d5fd-e4c0-4825-89f2-7cfb4a1cf01e",
  "expires_in":631138518,
  "scope":"/webhook"}

Register a webhook

Parameter Value
URL https://api.[host]/[ORCID iD]/webhook/[encoded url to call]
Method PUT
header Authorization: Bearer [Your authorization code]

Curl example:

Registering the URL https://nowhere2.com/0000-0002-7465-2162/updated for the record at http://sandbox.orcid.org/0000-0002-7465-2162.

curl -i -H "Authorization: Bearer 5eb23750-1e19-47a3-b6f6-26635c34e8ee"
  -X PUT "https://api.sandbox.orcid.org/0000-0002-7465-2162/webhook/https%3A%2F%2Fnowhere2.com%2F0000-0002-7465-2162%2Fupdated"

The response should be a 201 Created, but if the callback already existed, then the response will be 204 No Content.

Example response:

HTTP/1.1 201 Created
Server: nginx/1.1.19
Connection: keep-alive
Location: https://api.sandbox.orcid.org/0000-0002-7465-2162/webhook/https%3A%2F%2Fnowhere2.com%2F0000-0002-7465-2162%2Fupdated

Unregister a webhook

Parameter Value
URL https://api.[host]/[ORCID iD]/webhook/[encoded url]
Method DELETE
header Authorization: Bearer [Your authorization code]

The response should be 204 No Content.

Curl example:

curl -i -H "Authorization: Bearer 5eb23750-1e19-47a3-b6f6-26635c34e8ee"
  -X DELETE "https://api.sandbox.orcid.org/0000-0002-7465-2162/webhook/https%3A%2F%2Fnowhere2.com%2F0000-0002-7465-2162%2Fupdated"

Example response:

HTTP/1.1 204 No Content
Server: nginx/1.1.19
Date: Mon, 29 Jul 2013 14:36:11 GMT

Receiving the webhook call

Once a webhook is created you will get a callback to the registered url when the ORCID record is updated. Hook notifications are sent every five minutes to avoid multiple calls for a single user session. The ORCID Registry will do the following HTTPS call. The request uses the HTTPS POST method, but the body of the request is empty.

curl -v -X POST https://nowhere2.com/0000-0002-7253-3645/updated

Your server should respond with standard HTTP response codes: if the call was successful you should return 204 No Content. Any 2xx response code means that the call was successful. If you return a code that is not a 2xx, then we will continue to retry the call, doubling the time between each attempt.