POST
/companies/Create company
You can create a company.
| Attributes | Type | Required | Description |
|---|---|---|---|
| custom_id | string | no | The unique identifier for the company which is provided by the client. |
| address | string | no | A company’s address. |
| city | string | no | A company city of residence. |
| country | string | no | A company country of residence. |
| created_at | string | no | A creation date of a company. |
| description | string | no | A description of a company. |
| string(email) | no | A company’s email address. | |
| name | string | yes | A company name. |
| phone_numbers | string(list) | no | A list of phone numbers. |
| postal_code | string | no | A postal code according to the address of your company.. |
| region | string | no | A company region of residence. |
| size | integer | no | An approximate size of your company. |
| tags | string | no | A list of tags associated with a company |
| updated_at | string | no | A date of last company update. |
Request
- CURL
- JavaScript
- PHP
- Python
curl -X POST -H "Authorization: Token <your_64_char_api_key>" -H "Content-Type: application/json"
-H "Accept: */*; version=2" -d '{
"name": "1Company from API",
"description": "Company created by API request",
"email": "company@email.com",
"country": "United States",
"city": "Beverly Hills",
"postal_code": "90210",
"phone_numbers": [13102990912, 123456789]
}' "https://<your_app_subdomain>.user.com/api/public/companies/"
var data = JSON.stringify({
"name": "1Company from API",
"description": "Company created by API request",
"email": "company@email.com",
"country": "United States",
"city": "Beverly Hills",
"postal_code": "90210",
"phone_numbers": [
13102990912,
13123456789
]
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://<your_app_subdomain>.user.com/api/public/companies/");
xhr.setRequestHeader("authorization", "Token <your_64_char_api_key>");
xhr.setRequestHeader("accept", "*/*; version=2");
xhr.setRequestHeader("content-type", "application/json");
xhr.send(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/companies/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n \"name\": \"1Company from API\",\n \"description\": \"Company created by API request\",\n \"email\": \"company@email.com\",\n \"country\": \"United States\",\n \"city\": \"Beverly Hills\",\n \"postal_code\": \"90210\",\n \"phone_numbers\": [13102990912, 13123456789]\n \n}",
CURLOPT_HTTPHEADER => array(
"Accept: */*; version=2",
"authorization: Token <your_64_char_api_key>",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
import requests
url = "https://<your_app_subdomain>.user.com/api/public/companies/"
payload = "{\n \"name\": \"1Company from API\",\n \"description\": \"Company created by API request\",\n \"email\": \"company@email.com\",\n \"country\": \"United States\",\n \"city\": \"Beverly Hills\",\n \"postal_code\": \"90210\",\n \"phone_numbers\": [13102990912, 13123456789]\n \n}"
headers = {
'authorization': "Token <your_64_char_api_key>",
'Accept': "*/*; version=2",
'content-type': "application/json"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
Response
{
"id": 1666,
"name": "1Company from API",
"description": "Company created by API request",
"email": "company@email.com",
"country": "United States",
"region": null,
"city": "Beverly Hills",
"address": null,
"postal_code": "90210",
"approx_employees": null,
"created_at": "2017-07-06T15:39:25.513985Z",
"updated_at": "2017-07-06T15:39:25.514009Z",
"phone_numbers": [
"13102990912",
"13123456789"
],
"company_id": null,
"employees": [123, 432, 543]
}