Create unit
curl --request POST \
--url https://api.example.com/units \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"reference": "<string>",
"parent_id": 123,
"description": "<string>"
}
'import requests
url = "https://api.example.com/units"
payload = {
"name": "<string>",
"reference": "<string>",
"parent_id": 123,
"description": "<string>"
}
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({
name: '<string>',
reference: '<string>',
parent_id: 123,
description: '<string>'
})
};
fetch('https://api.example.com/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/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([
'name' => '<string>',
'reference' => '<string>',
'parent_id' => 123,
'description' => '<string>'
]),
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/units"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"reference\": \"<string>\",\n \"parent_id\": 123,\n \"description\": \"<string>\"\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/units")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"reference\": \"<string>\",\n \"parent_id\": 123,\n \"description\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/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 \"name\": \"<string>\",\n \"reference\": \"<string>\",\n \"parent_id\": 123,\n \"description\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"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"
}Units
Create unit
Creates a new unit and returns the created resource.
POST
/
units
Create unit
curl --request POST \
--url https://api.example.com/units \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"reference": "<string>",
"parent_id": 123,
"description": "<string>"
}
'import requests
url = "https://api.example.com/units"
payload = {
"name": "<string>",
"reference": "<string>",
"parent_id": 123,
"description": "<string>"
}
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({
name: '<string>',
reference: '<string>',
parent_id: 123,
description: '<string>'
})
};
fetch('https://api.example.com/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/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([
'name' => '<string>',
'reference' => '<string>',
'parent_id' => 123,
'description' => '<string>'
]),
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/units"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"reference\": \"<string>\",\n \"parent_id\": 123,\n \"description\": \"<string>\"\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/units")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"reference\": \"<string>\",\n \"parent_id\": 123,\n \"description\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/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 \"name\": \"<string>\",\n \"reference\": \"<string>\",\n \"parent_id\": 123,\n \"description\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"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"
}Body
application/json
Response
Unit created
Example:
"unit"
Example:
1
Example:
"HQ"
Depth in unit tree
Materialized path
Example:
"unit"
From pivot when in context
Parent unit when loaded
Unit image when loaded
Company, delivery, invoicing addresses
Contact name and phone
Office hours and closed days
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Permission flags for current user
Example:
"api/units/1"
⌘I