Create User Group
curl --request POST \
--url https://api.lemlist.com/api/v2/user-groups \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "UK",
"userIds": [
"usr_ExAmPlE123456789a",
"usr_ExAmPlE123456789b"
]
}
'import requests
url = "https://api.lemlist.com/api/v2/user-groups"
payload = {
"name": "UK",
"userIds": ["usr_ExAmPlE123456789a", "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({name: 'UK', userIds: ['usr_ExAmPlE123456789a', 'usr_ExAmPlE123456789b']})
};
fetch('https://api.lemlist.com/api/v2/user-groups', 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")
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 \"name\": \"UK\",\n \"userIds\": [\n \"usr_ExAmPlE123456789a\",\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",
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([
'name' => 'UK',
'userIds' => [
'usr_ExAmPlE123456789a',
'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_ExAmPlE123456789b"
]
}
}{
"error": "Invalid request: name holds 1 to 60 characters once trimmed, userIds is an array of at most 1,000 user ids, a PATCH sends name or userIds, and no user is both added and removed",
"code": "USER_GROUPS_INVALID_REQUEST"
}{
"error": "Route unauthorized",
"code": "ROUTE_UNAUTHORIZED"
}{
"error": "User not authorized",
"code": "USER_NOT_AUTHORIZED"
}{
"error": "A user group already has this name",
"code": "USER_GROUPS_NAME_TAKEN"
}{
"error": "Internal error",
"code": "INTERNAL_ERROR"
}User Groups
Create User Group
Creates a user group with its members.
POST
/
v2
/
user-groups
Create User Group
curl --request POST \
--url https://api.lemlist.com/api/v2/user-groups \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "UK",
"userIds": [
"usr_ExAmPlE123456789a",
"usr_ExAmPlE123456789b"
]
}
'import requests
url = "https://api.lemlist.com/api/v2/user-groups"
payload = {
"name": "UK",
"userIds": ["usr_ExAmPlE123456789a", "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({name: 'UK', userIds: ['usr_ExAmPlE123456789a', 'usr_ExAmPlE123456789b']})
};
fetch('https://api.lemlist.com/api/v2/user-groups', 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")
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 \"name\": \"UK\",\n \"userIds\": [\n \"usr_ExAmPlE123456789a\",\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",
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([
'name' => 'UK',
'userIds' => [
'usr_ExAmPlE123456789a',
'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_ExAmPlE123456789b"
]
}
}{
"error": "Invalid request: name holds 1 to 60 characters once trimmed, userIds is an array of at most 1,000 user ids, a PATCH sends name or userIds, and no user is both added and removed",
"code": "USER_GROUPS_INVALID_REQUEST"
}{
"error": "Route unauthorized",
"code": "ROUTE_UNAUTHORIZED"
}{
"error": "User not authorized",
"code": "USER_NOT_AUTHORIZED"
}{
"error": "A user group already has this name",
"code": "USER_GROUPS_NAME_TAKEN"
}{
"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 | name is empty once trimmed or longer than 60 characters, or userIds is not an array of at most 1,000 user ids. |
USER_NOT_IN_TEAM | A user id 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_NAME_TAKEN | Your team already has a group with this name, whatever its case. |
USER_GROUPS_LIMIT_REACHED | Your team already has 100 groups. |
Authorizations
Body
application/json
Was this page helpful?