POST/ companies/ :id/ remove_member/
Company remove member
You can remove an employee (a user) added to the company.
Attributes
Optional unless marked required
- id
- A unique identifier for the company which is given by User automatically.
- user_id
- A unique identifier for the user which is given by User automatically. Send this or
user_custom_id. - user_custom_id
- A unique identifier for the user which is provided by the client. Send this or
user_id.
Send one of user_id and user_custom_id to point at the contact.
Request
- cURL
- JavaScript
- PHP
- Python
curl -X POST "https://<your_app_subdomain>.user.com/api/public/companies/:id/remove_member/" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2" \
-H "Content-Type: application/json" \
-d '{
"user_id": 1884
}'
const response = await fetch(
"https://<your_app_subdomain>.user.com/api/public/companies/:id/remove_member/",
{
method: "POST",
headers: {
Authorization: "Token <your_64_char_api_key>",
Accept: "*/*; version=2",
"Content-Type": "application/json",
},
body: JSON.stringify({
user_id: 1884,
}),
},
);
const data = await response.json();
console.log(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/companies/:id/remove_member/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Token <your_64_char_api_key>",
"Accept: */*; version=2",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"user_id" => 1884,
]),
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
response = requests.post(
"https://<your_app_subdomain>.user.com/api/public/companies/:id/remove_member/",
headers={
"Authorization": "Token <your_64_char_api_key>",
"Accept": "*/*; version=2",
},
json={
"user_id": 1884,
},
)
print(response.json())
Response examples
- 202 Accepted
- 400 Bad Request
- 404 Not Found
No response body.
{
"success": false,
"error": "User with id 123 is not a member of the company"
}
{
"detail": "No Company matches the given query."
}
When the contact can't be removed, the response is 400 with "success": false and one of these messages:
| Message | When |
|---|---|
User with id 123 is not a member of the company | The contact isn't a member of this company, or no contact has that user_id. |
User with id None is not a member of the company | The body has neither user_id nor user_custom_id, or no contact has that user_custom_id. |
note
Errors that can come from any endpoint (401, 429, 500, 502, 504) are described in HTTP response codes.