How to get the company domain

There are a few methods for getting the value of the subdomain for a Pipedrive company for which we use the company_domain parameter:



Method 1


You can get it manually from the Pipedrive app by logging into your Developer Sandbox account and seeing the URL:

1480

Method 2


You can fetch it via GET /users/me. Just copy the code below to your favorite editor and don't forget to replace the text with your actual API token. Execute the code and get the company_domain from the output:

<?php

$api_token = 'Your API token';
$url = 'https://api.pipedrive.com/v1/users/me?api_token=' . $api_token;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

echo 'Sending request...' . PHP_EOL;

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

$result = json_decode($output, true);

if (!empty($result['data']['company_domain'])) {
  echo 'User company_domain is: ' . $result['data']['company_domain'] . PHP_EOL;
}

You can check the GET /users/me response JSON here.



Method 3


If you’re using OAuth authorization you can get the company_domain in the OAuth server's response when making a HTTP request to it. In the JSON response body, company_domain will be a part of the api_domain parameter's value.

More info can be found about it in the getting the OAuth tokens and refreshing the OAuth tokens sections.