Authentication

Authentication with our API is done with API Tokens. These are special passwords that allow your code to authenticate with our API.

Each Bucket that you create will be issued a unique API Token. Make sure you save these in a safe spot because they can only be displayed once. If you forget an API Token, or need to get a new one, you can edit the Bucket and generate a new API Token at any time. This will immediately invalidate any old API Tokens currently in use for this bucket. An API Token can only be used to manage the Microtasks within its own bucket. To avoid revealing your API Token, all requests to the API should be made over a secure HTTPS SSL connection.

There are three different ways to use an API Token to make a request

Query String

For GET requests, you can simply include the API Token into the query string

https://www.t4sk.dev/api/task?api_token=1a2b3c4d5e6f7
Request Payload

For POST requests, you can include the API Token in the form's payload.

Params = [
	'api_token' => '1a2b3c4d5e6f7',
	...
]
Response = HTTP_Request('POST', '/task', Params)
Request Header

For any type of request, you can put the API Token into the request header as a Bearer token.

Params = [ ... ]

Headers = [
	'Accept' => 'application/json',
	'Authorization: Bearer 1a2b3c4d5e6f7'
]

Response = HTTP_Request('POST', '/task', Params, Headers)
PHP Curl Example
function HTTP_Request($path, $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);

	$result = curl_exec($ch);
	curl_close($ch);

	return json_decode($result);
}

$response = HTTP_Request('https://www.t4sk.dev/api/task/1234', $api_token);