Add users to a permission group
curl --request POST \
--url https://api.nekt.ai/api/v1/organization/permission-groups/{permission_group_pk}/users/ \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"users": [
123
]
}
'import requests
url = "https://api.nekt.ai/api/v1/organization/permission-groups/{permission_group_pk}/users/"
payload = { "users": [123] }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({users: [123]})
};
fetch('https://api.nekt.ai/api/v1/organization/permission-groups/{permission_group_pk}/users/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.nekt.ai/api/v1/organization/permission-groups/{permission_group_pk}/users/",
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([
'users' => [
123
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.nekt.ai/api/v1/organization/permission-groups/{permission_group_pk}/users/"
payload := strings.NewReader("{\n \"users\": [\n 123\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.nekt.ai/api/v1/organization/permission-groups/{permission_group_pk}/users/")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"users\": [\n 123\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.nekt.ai/api/v1/organization/permission-groups/{permission_group_pk}/users/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"users\": [\n 123\n ]\n}"
response = http.request(request)
puts response.read_bodyPermission groups
Add Group Members
Put people in a group, and hand them everything it holds.
POST
/
api
/
v1
/
organization
/
permission-groups
/
{permission_group_pk}
/
users
/
Add users to a permission group
curl --request POST \
--url https://api.nekt.ai/api/v1/organization/permission-groups/{permission_group_pk}/users/ \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"users": [
123
]
}
'import requests
url = "https://api.nekt.ai/api/v1/organization/permission-groups/{permission_group_pk}/users/"
payload = { "users": [123] }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({users: [123]})
};
fetch('https://api.nekt.ai/api/v1/organization/permission-groups/{permission_group_pk}/users/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.nekt.ai/api/v1/organization/permission-groups/{permission_group_pk}/users/",
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([
'users' => [
123
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.nekt.ai/api/v1/organization/permission-groups/{permission_group_pk}/users/"
payload := strings.NewReader("{\n \"users\": [\n 123\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.nekt.ai/api/v1/organization/permission-groups/{permission_group_pk}/users/")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"users\": [\n 123\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.nekt.ai/api/v1/organization/permission-groups/{permission_group_pk}/users/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"users\": [\n 123\n ]\n}"
response = http.request(request)
puts response.read_bodyAdds users to a group without touching the people already in it. They gain every grant the group holds, on all three permission axes, immediately — no permission call.
Request body
| Parameter | Type | Required | Description |
|---|---|---|---|
users | array of integers | Yes | User ids to add. Ids already in the group are ignored. |
curl --request POST \
--url https://api.nekt.ai/api/v1/organization/permission-groups/GROUP_ID/users/ \
--header "x-api-key: YOUR_API_KEY" \
--header "Content-Type: application/json" \
--data '{"users": [12, 42]}'
Response
204, with no body. Read the membership back with List Members if you need to confirm it.
Invited users can be added before they accept
This is the middle step of onboarding, and it is why an invitation provisions the user immediately. Invite, group, and the grants are waiting for them the moment they accept.import os
import requests
BASE_URL = "https://api.nekt.ai"
headers = {"x-api-key": os.environ["NEKT_API_KEY"], "Content-Type": "application/json"}
invite = requests.post(
f"{BASE_URL}/api/v1/invitations/",
headers=headers,
json={"email": "analyst@example.com", "role": "member"},
)
invite.raise_for_status()
# They exist now, pending, and can hold access. Find their user id as a recipient.
recipients = requests.get(
f"{BASE_URL}/api/v1/permission-recipients/",
headers=headers,
params={"expand[]": "users", "search": "analyst@example.com"},
).json()
user_id = recipients["users"][0]["id"]
requests.post(
f"{BASE_URL}/api/v1/organization/permission-groups/GROUP_ID/users/",
headers=headers,
json={"users": [user_id]},
).raise_for_status()
Invite as
member. Owners and Admins bypass data-level permissions entirely, so grouping them changes nothing.Errors
| Status | When |
|---|---|
400 | A user id belongs to a deactivated member. |
400 | The group is the All group, which contains everybody automatically. |
403 | Your API key was created by a Member. |
404 | No group with that id in your workspace. |
Related
- Remove Members — the reverse.
- Update a Group — replacing the whole membership instead.
- Onboarding flow — invite, group, and grant in one script.
Authorizations
API Key authentication. Format: 'x-api-key: api_key'
Path Parameters
The permission group's id.
Body
application/jsonapplication/x-www-form-urlencodedmultipart/form-data
Response
204
The users were added to the group.
Was this page helpful?