Creating Microtasks

Whenever work becomes available within your project, you can use this API method to create microtasks within your T4SK account.

To create a Microtask, you must make a POST request to the '/api/task' endpoint with all the necessary fields filled out.

For Yes/No, Multiple Choice and Fill in the Blank Microtasks, the website will automatically create the inputs and buttons for you. If you are creating an HTML Form type question, you will need to create the inputs in the body of the question. You should not create the <form> tags or the submit button. We'll take care of that for you by wrapping the entire thing in a form. You just need to provide the inputs (text boxes, checkboxes, radio buttons, etc) that would go inside the form.

PHP Curl Example
function HTTP_Post($path, $fields, $api_token) {
	$headers = array('Accept: application/json', "Authorization: Bearer ".$api_token);

	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $path);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	curl_setopt($ch, CURLOPT_POST, true);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);

	$result = curl_exec($ch);

	return json_decode($result);

$microtask1 = array(
	'type' => 'multi',
	'priority' => 10,
	'title' => 'An Important Question',
	'question' => 'What is your <b>favorite</b> color?',
	'answers' => json_encode(array('Red','Blue','Green','Black','White')),
	'passthrough_data' => '12345'

$microtask2 = array(
	'type' => 'form',
	'priority' => 10,
	'title' => 'An Important Question',
	'question' => 'Enter two words that rhyme: <input type="text" name="word1"> <input type="text" name="word2">',
	'passthrough_data' => '12346'

$response = HTTP_Post('', $microtask1, $api_token);
$response = HTTP_Post('', $microtask2, $api_token);

If the Microtask was successfully created, the API will return the record that was created, including the newly created unique ID number that you may way to record.

Example response:

    [data] => stdClass Object
            [id] => 1234
            [is_html] => 1
            [title] => An Important Question
            [priority] => 1
            [type] => 'multi'
            [question] => ...
            [answers] => ...
            [num_answers] => 2
            [num_entered] => 0
            [can_super] => 1
            [completed_at] => ...
            [final_answer] => ...
            [passthrough_data] => ...
            [created_at] => 2020-05-06T17:12:47.000000Z