Follow

CrowdFlower Webhook Basics

Webhooks provide callbacks between your web application and CrowdFlower. This integration point allows developers to create robust applications that interact with CrowdFlower and take actions based on the results that the platform provides.
 

Note: In this article, rows are referred to as "units".

Basics

Webhooks are enabled by setting the webhook_uri property for a Job.

When a webhook is enabled for a Job, CrowdFlower will post to that URL whenever an interesting event happens in your Job (see table below). Each POST will feature three parameters: signal, payload and signature.

  • The signal describes the type of event that has occurred. Results for a row will be delivered with a unit_complete signal.
  • The payload parameter will contain a JSON representation of the associated object. For example, when your job completes, you will receive the job_complete signal, and the associated payload will be a JSON representation of that Job.
  • The signature contains a SHA1 encrypted version of your API key concatenated with the payload. (i.e., signature = sha1.encrypt( payload + api_key ).
  • unit_complete ​is the most frequently used webhook. The unit_complete payload includes all of the Judgments for the work completed, as well as additional useful aggregate statistics.

Note that the unit_complete event does not apply to test questions. To manually send webhooks for test questions, send a GET request to: https://api.crowdflower.com/v1/jobs/{job_id}/golds/fire_webhooks

 

Judgment Webhooks

You must set the send_judgments_webhook attribute on your Job to TRUE via a PUT request receive a webhook for every new judgment that your data collects:
curl -X PUT -d "job[send_judgments_webhook]=true" https://api.crowdflower.com/v1/jobs/{job_id}.json?key={api_key}

 

Error Handling

The CrowdFlower platform will retry posting the webhook several times with exponential backoff, if it encounters difficulties reaching your servers. A total of 30 attempts will be made to a failing webhook over the course of 165 minutes, with the first wait between attempts lasting 5 seconds and the last wait lasting 30 minutes. If the webhook is unsuccessful after the last attempt, we will automatically disable it - deleting your webhook_uri from the job's settings - and send an email informing you of the problem.

 

A post is considered a failure if your endpoint:

  • responds with a non-200 status code,
  • responds with a body including invalid JSON, and/or
  • takes longer than 5 seconds to respond.

 

To keep the Webhook up and running correctly, please ensure that your server responds to each POST from CrowdFlower within 5 seconds, with an HTTP 200 (OK) header and an empty body (or valid JSON).

 

Events

SignalDescriptionPayload
unit_complete One Row of work has all the judgments it needs. Row
new_judgments Judgments were submitted. Judgment
job_data_processed The data uploaded for this Job has been processed. Job
job_complete All the judgments for the Job have been completed. Job
 

 

Webhook Security

Using the webhook's signature: You will be able to sign CrowdFlower's posts by validating the sha1 signature attribute in the body of the payload.  The signature is a sha1 encrypted string of the unparsed payload concatenated with your secret API key ( i.e., signature = sha1.encrypt( payload + your_api_key ) ). You can validate the webhook by generating the same sha1 and comparing it to the signature sent with the payload ( e.g., webhook.valid? if payload[:signature] == sha1.encrypt( payload + my_api_key ) )

 

Via basic authentication: If your endpoint (webhook) supports basic authentication, you can set the webhook in your job using the following convention: 'http://username:password@webhook'. The webhook will be posted to your server using HTTP basic authentication via the username:password credentials that you provide.

 

CrowdFlower IP Whitelist: CrowdFlower does not maintain a whitelist of the IPs posting webhooks from our applications.


Was this article helpful?
0 out of 0 found this helpful


Have more questions? Submit a request
Powered by Zendesk