Webhooks can be used to receive notification of any changes in job status.
Currently, webhooks can only be defined by using Clara’s REST API. POST to https://clara.io/api/webhooks to create a webhook.
The following parameters are required:
The following parameters are optional:
As with any clara.io REST API you may POST with content-type application/x-www-form-urlencoded
, application/form-data
or application/json
.
When the webhook fires, data will be sent to your URL with content-type application/json
.
content-type application/x-www-form-urlencoded
curl https://clara.io/api/webhooks \
-X POST -u yourname:25ea87a1-1301-4bc4-9430-55112753e6a3 \
-d "url=http://foo.example.com/hook" \
-d "statuses[]=ok" \
-d "statuses[]=failed" \
-d "jobTypes[]=export" \
-d "jobTypes[]=import" \
-d "active=true"
content-type application/json
curl https://clara.io/api/webhooks \
-X POST -u yourname:25ea87a1-1301-4bc4-9430-55112753e6a3 \
-H "Content-Type: application/json" \
-d '{
"url": "https://foo.example.com/hook",
"statuses": ["ok", "failed"],
"jobTypes": ["export", "import"],
"active": true
}'
PUT to https://clara.io/api/webhooks/${_id}
GET https://clara.io/api/webhooks
When executing a webhook, Clara.io sends job data with content-type application/json
. The job data may contain the following fields:
Posts to your webhook’s URL will contain the following headers:
The X-Clara-Signature
header is created with the following node.js expression:
'sha256='+crypto.createHmac('sha256', hook.secret).update(body).digest('hex')
It can be verified in Ruby with:
def verify_signature(payload_body)
signature = 'sha256=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), ENV['SECRET_TOKEN'], payload_body)
return halt 500, "Signatures didn't match!" unless Rack::Utils.secure_compare(signature, request.env['HTTP_X_CLARA_SIGNATURE'])
end
When using the Clara Node SDK:
$ clara webhooks:list [options]
$ clara webhooks:create [options]
$ clara webhooks:update [options]