Add unit membership
curl --request POST \
--url https://api.example.com/users/{user}/units \
--header 'Content-Type: application/json' \
--data '
{
"unit": 123,
"userTypes": [
123
]
}
'import requests
url = "https://api.example.com/users/{user}/units"
payload = {
"unit": 123,
"userTypes": [123]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({unit: 123, userTypes: [123]})
};
fetch('https://api.example.com/users/{user}/units', 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.example.com/users/{user}/units",
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([
'unit' => 123,
'userTypes' => [
123
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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.example.com/users/{user}/units"
payload := strings.NewReader("{\n \"unit\": 123,\n \"userTypes\": [\n 123\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/users/{user}/units")
.header("Content-Type", "application/json")
.body("{\n \"unit\": 123,\n \"userTypes\": [\n 123\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/users/{user}/units")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"unit\": 123,\n \"userTypes\": [\n 123\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": 1,
"abilities": {},
"unit": {
"content_type": "unit",
"id": 1,
"reference": "<string>",
"name": "HQ",
"description": "<string>",
"level": 123,
"path": "<string>",
"unit_type": "unit",
"falldown": true,
"features": [
{}
],
"departments": [
{}
],
"parent": {},
"image": {},
"children": [
{}
],
"addresses": {},
"contact": {},
"opening_hours": {},
"geo": {
"lat": 123,
"lng": 123
},
"stats": {
"users": 123,
"children": 123,
"children_total": 123
},
"permissions": {},
"url": "api/units/1"
},
"department": {},
"userTypes": [
{}
],
"permissions": {
"edit": true,
"delete": true
},
"integrationMemberships": [
{}
]
}User unit memberships
Add unit membership
Creates or updates a unit membership for the user (unit, department, user types). Returns the membership and sets Location header.
POST
/
users
/
{user}
/
units
Add unit membership
curl --request POST \
--url https://api.example.com/users/{user}/units \
--header 'Content-Type: application/json' \
--data '
{
"unit": 123,
"userTypes": [
123
]
}
'import requests
url = "https://api.example.com/users/{user}/units"
payload = {
"unit": 123,
"userTypes": [123]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({unit: 123, userTypes: [123]})
};
fetch('https://api.example.com/users/{user}/units', 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.example.com/users/{user}/units",
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([
'unit' => 123,
'userTypes' => [
123
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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.example.com/users/{user}/units"
payload := strings.NewReader("{\n \"unit\": 123,\n \"userTypes\": [\n 123\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/users/{user}/units")
.header("Content-Type", "application/json")
.body("{\n \"unit\": 123,\n \"userTypes\": [\n 123\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/users/{user}/units")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"unit\": 123,\n \"userTypes\": [\n 123\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": 1,
"abilities": {},
"unit": {
"content_type": "unit",
"id": 1,
"reference": "<string>",
"name": "HQ",
"description": "<string>",
"level": 123,
"path": "<string>",
"unit_type": "unit",
"falldown": true,
"features": [
{}
],
"departments": [
{}
],
"parent": {},
"image": {},
"children": [
{}
],
"addresses": {},
"contact": {},
"opening_hours": {},
"geo": {
"lat": 123,
"lng": 123
},
"stats": {
"users": 123,
"children": 123,
"children_total": 123
},
"permissions": {},
"url": "api/units/1"
},
"department": {},
"userTypes": [
{}
],
"permissions": {
"edit": true,
"delete": true
},
"integrationMemberships": [
{}
]
}Path Parameters
User ID
Response
Unit membership created
Example:
1
Permission abilities when permissions relation loaded
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Department when loaded
User types when loaded
Current user permission flags when includePermissions set
Show child attributes
Show child attributes
Integration memberships when loaded
⌘I