Edit User Group Members
curl --request POST \
--url https://api.lemlist.com/api/v2/user-groups/{userGroupId}/members \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"addUserIds": [
"usr_ExAmPlE123456789c"
],
"removeUserIds": [
"usr_ExAmPlE123456789b"
]
}
'import requests
url = "https://api.lemlist.com/api/v2/user-groups/{userGroupId}/members"
payload = {
"addUserIds": ["usr_ExAmPlE123456789c"],
"removeUserIds": ["usr_ExAmPlE123456789b"]
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
addUserIds: ['usr_ExAmPlE123456789c'],
removeUserIds: ['usr_ExAmPlE123456789b']
})
};
fetch('https://api.lemlist.com/api/v2/user-groups/{userGroupId}/members', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));require 'uri'
require 'net/http'
url = URI("https://api.lemlist.com/api/v2/user-groups/{userGroupId}/members")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"addUserIds\": [\n \"usr_ExAmPlE123456789c\"\n ],\n \"removeUserIds\": [\n \"usr_ExAmPlE123456789b\"\n ]\n}"
response = http.request(request)
puts response.read_body<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.lemlist.com/api/v2/user-groups/{userGroupId}/members",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'addUserIds' => [
'usr_ExAmPlE123456789c'
],
'removeUserIds' => [
'usr_ExAmPlE123456789b'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"data": {
"id": "ugr_ExAmPlE123456789a",
"name": "UK",
"userIds": [
"usr_ExAmPlE123456789a",
"usr_ExAmPlE123456789c"
]
}
}{
"error": "This user is not a member of this team",
"code": "USER_NOT_IN_TEAM"
}{
"error": "Route unauthorized",
"code": "ROUTE_UNAUTHORIZED"
}{
"error": "User not authorized",
"code": "USER_NOT_AUTHORIZED"
}{
"error": "This user group no longer exists",
"code": "USER_GROUPS_NOT_FOUND"
}{
"error": "This user group has reached the maximum number of members",
"code": "USER_GROUPS_USERS_LIMIT_REACHED"
}{
"error": "Internal error",
"code": "INTERNAL_ERROR"
}User Groups
Edit User Group Members
Adds and removes members of a user group without sending the whole list.
POST
/
v2
/
user-groups
/
{userGroupId}
/
members
Edit User Group Members
curl --request POST \
--url https://api.lemlist.com/api/v2/user-groups/{userGroupId}/members \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"addUserIds": [
"usr_ExAmPlE123456789c"
],
"removeUserIds": [
"usr_ExAmPlE123456789b"
]
}
'import requests
url = "https://api.lemlist.com/api/v2/user-groups/{userGroupId}/members"
payload = {
"addUserIds": ["usr_ExAmPlE123456789c"],
"removeUserIds": ["usr_ExAmPlE123456789b"]
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
addUserIds: ['usr_ExAmPlE123456789c'],
removeUserIds: ['usr_ExAmPlE123456789b']
})
};
fetch('https://api.lemlist.com/api/v2/user-groups/{userGroupId}/members', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));require 'uri'
require 'net/http'
url = URI("https://api.lemlist.com/api/v2/user-groups/{userGroupId}/members")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"addUserIds\": [\n \"usr_ExAmPlE123456789c\"\n ],\n \"removeUserIds\": [\n \"usr_ExAmPlE123456789b\"\n ]\n}"
response = http.request(request)
puts response.read_body<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.lemlist.com/api/v2/user-groups/{userGroupId}/members",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'addUserIds' => [
'usr_ExAmPlE123456789c'
],
'removeUserIds' => [
'usr_ExAmPlE123456789b'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"data": {
"id": "ugr_ExAmPlE123456789a",
"name": "UK",
"userIds": [
"usr_ExAmPlE123456789a",
"usr_ExAmPlE123456789c"
]
}
}{
"error": "This user is not a member of this team",
"code": "USER_NOT_IN_TEAM"
}{
"error": "Route unauthorized",
"code": "ROUTE_UNAUTHORIZED"
}{
"error": "User not authorized",
"code": "USER_NOT_AUTHORIZED"
}{
"error": "This user group no longer exists",
"code": "USER_GROUPS_NOT_FOUND"
}{
"error": "This user group has reached the maximum number of members",
"code": "USER_GROUPS_USERS_LIMIT_REACHED"
}{
"error": "Internal error",
"code": "INTERNAL_ERROR"
}User groups are in beta. To use these endpoints now, contact your lemlist
account manager.
Admins only: the API key must have been created by an admin of the team.
Error codes
| Code | Cause |
|---|---|
USER_GROUPS_INVALID_REQUEST | A list is not an array of at most 1,000 user ids, or a user is both added and removed. |
USER_NOT_IN_TEAM | An added user is not a member of your team. |
USER_GROUPS_PLAN_REQUIRED | Your team is not on the Enterprise plan, or the user groups beta is not enabled for it. |
USER_NOT_AUTHORIZED | The API key was created by a team member who is not an admin. |
USER_GROUPS_NOT_FOUND | No group with this id in your team. |
USER_GROUPS_USERS_LIMIT_REACHED | The group would hold more than 1,000 members. |
Authorizations
Path Parameters
Body
application/json
Was this page helpful?