Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
    Brian Nguyen
    I'm trying to make a call to corptools but it failed with 401

    $access_key = '';
    $secret_key = '';
    $base_url = 'https://api.corporatetools.com';
    $request_path = '/companies';
    $query_string = '?limit=1';
    $request_body = '';
    $header = json_encode([
    'typ' => 'JWT',
    'alg' => 'HS256',
    'access_key' => $access_key,
    $payload = json_encode([
    'path' => $request_path,
    'content' => hash('sha256', $query_string . $request_body)
    $e_header = strreplace(['+', '/', '='], ['-', '', ''], base64_encode($header));
    $e_payload = strreplace(['+', '/', '='], ['-', '', ''], base64_encode($payload));
    $signature = hash_hmac('sha256', $e_header . '.' . $e_payload, $secret_key, true);
    $e_signature = strreplace(['+', '/', '='], ['-', '', ''], base64_encode($signature));
    $jwt = $e_header . '.' . $e_payload . '.' . $e_signature;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $base_url . $request_path . $query_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    //curl_setopt($ch, CURLOPT_POSTFIELDS, $request_body);
    curl_setopt($ch, CURLOPT_POST, 0);
    curl_setopt($ch, CURLOPT_HTTPGET, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer $jwt",
    'Content-Type: application/json',
    'Accept: application/json'

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);

    $result = curl_exec($ch);

    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); // this results 0 every time
    $http_res_code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE); // this results 0 every time
    if (curl_errno($ch)) {
    die ('Error:' . curl_error($ch));
    if (! empty($http_res_code) && $http_res_code <> 200) die ("http response code: ${http_res_code}");
    echo '<pre>';
    echo json_encode(json_decode($result), JSON_PRETTY_PRINT);
    echo '</pre>';

    Corptools API

    Hey Brian, how are you doing? I was looking into your code this morning and it looks like the ? should be moved to a different line:

    $query_string = 'limit=1';
    curl_setopt($ch, CURLOPT_URL, $base_url . $request_path . '?' . $query_string);

    I attempted to add an offset to the query string: $query_string = 'limit=1&offset=1'; but that too causes a 401 error so I am now looking into that and will let you know if I find anything.

    Corptools API
    Good afternoon! I am happy to report that we deployed changes to our API that will make query string validation more forgiving. This means you should run into fewer 401 errors, but we still want you to reach out if you need assistance. Going forward, you should no longer need to add query_string to your payload content. Feel free to test it out and let me know if it works.
    Brian Nguyen
    Thanks, it works now. Actually I still keep the ? in the query string like this
    $query_string = '?limit=1';
    curl_setopt($ch, CURLOPT_URL, $base_url . $request_path . $query_string);
    I think because you removed the need to add query string, it works much better now
    $payload = json_encode([
    'path' => $request_path,
    'content' => hash('sha256', $request_body)
    Thank you very much. I'll start adding services using your API now.
    Corptools API
    Glad I could help. Reach out whenever you want
    Brian Nguyen
    It always returns invalid website url . What should be the website url?
    @corporatetools I am trying to connect to the API for the first time and I am getting 401s. I am using apex (Salesforce) so posting the code is probably useless, also leary about posting my keys. If I sent you a JWT could you tell me if it was valid for the /companies request?
    1 reply
    Cade Parker
    @corporatetools is there any rate-limits in place on API accounts? I've noticed 429 listed as a status code in the errors documentation, but i don't see what would cause that. We need to update services for all of our companies and want to be sure we arent going to hit something like that
    Randy Classen
    Hi @corporatetools , I'm hitting the GET /documents endpoint and it works great with either a start or a stop parameter but I get a 500 when I include both.
    While trying to download corporate phone app in UAE, there is a error message “ App is not available in your region” plz fix…