Upsert group attributions bulk
curl --request PUT \
--url https://api.qobra.co/v1/users/groups/bulk \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"data": [
{
"user": "user-1@company.com",
"group_dimension": "country",
"group": "france",
"start_date": "2023-01",
"end_date": "2023-10"
},
{
"user": "user-2@company.com",
"manager": "manager-2@company.com"
},
"..."
]
}
'import requests
url = "https://api.qobra.co/v1/users/groups/bulk"
payload = { "data": [
{
"user": "user-1@company.com",
"group_dimension": "country",
"group": "france",
"start_date": "2023-01",
"end_date": "2023-10"
},
{
"user": "user-2@company.com",
"manager": "manager-2@company.com"
},
"..."
] }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: [
{
user: 'user-1@company.com',
group_dimension: 'country',
group: 'france',
start_date: '2023-01',
end_date: '2023-10'
},
{user: 'user-2@company.com', manager: 'manager-2@company.com'},
'...'
]
})
};
fetch('https://api.qobra.co/v1/users/groups/bulk', 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.qobra.co/v1/users/groups/bulk",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
[
'user' => 'user-1@company.com',
'group_dimension' => 'country',
'group' => 'france',
'start_date' => '2023-01',
'end_date' => '2023-10'
],
[
'user' => 'user-2@company.com',
'manager' => 'manager-2@company.com'
],
'...'
]
]),
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.qobra.co/v1/users/groups/bulk"
payload := strings.NewReader("{\n \"data\": [\n {\n \"user\": \"user-1@company.com\",\n \"group_dimension\": \"country\",\n \"group\": \"france\",\n \"start_date\": \"2023-01\",\n \"end_date\": \"2023-10\"\n },\n {\n \"user\": \"user-2@company.com\",\n \"manager\": \"manager-2@company.com\"\n },\n \"...\"\n ]\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.qobra.co/v1/users/groups/bulk")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": [\n {\n \"user\": \"user-1@company.com\",\n \"group_dimension\": \"country\",\n \"group\": \"france\",\n \"start_date\": \"2023-01\",\n \"end_date\": \"2023-10\"\n },\n {\n \"user\": \"user-2@company.com\",\n \"manager\": \"manager-2@company.com\"\n },\n \"...\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.qobra.co/v1/users/groups/bulk")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": [\n {\n \"user\": \"user-1@company.com\",\n \"group_dimension\": \"country\",\n \"group\": \"france\",\n \"start_date\": \"2023-01\",\n \"end_date\": \"2023-10\"\n },\n {\n \"user\": \"user-2@company.com\",\n \"manager\": \"manager-2@company.com\"\n },\n \"...\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"count": "<Upserted manager relationships count>",
"data": [
{
"user": "user-1@company.com",
"group_dimension": "country",
"group": "france",
"start_date": "2023-01",
"end_date": "2023-10"
},
{
"user": "user@company.com",
"group_dimension": "country",
"group": "belgium",
"start_date": "2023-03",
"end_date": null
},
"..."
]
}{
"count": "<Errors count>",
"errors": [
{
"error": "NotFoundError",
"user": "user-3@company.com",
"resource": "group_dimension",
"description": "Group dimension not found for country"
},
{
"error": "NotFoundError",
"user": "user-4@company.com",
"resource": "group",
"description": "Group not found for france"
},
{
"error": "ParsingError",
"user": "user-test-4@company.com",
"resource": "<field_name>",
"description": "We had issues parsing the <field_name> provided : value <value_received>"
},
"..."
]
}Group attributions
Upsert group attributions bulk
Upsert group attributions in bulk.
PUT
/
v1
/
users
/
groups
/
bulk
Upsert group attributions bulk
curl --request PUT \
--url https://api.qobra.co/v1/users/groups/bulk \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"data": [
{
"user": "user-1@company.com",
"group_dimension": "country",
"group": "france",
"start_date": "2023-01",
"end_date": "2023-10"
},
{
"user": "user-2@company.com",
"manager": "manager-2@company.com"
},
"..."
]
}
'import requests
url = "https://api.qobra.co/v1/users/groups/bulk"
payload = { "data": [
{
"user": "user-1@company.com",
"group_dimension": "country",
"group": "france",
"start_date": "2023-01",
"end_date": "2023-10"
},
{
"user": "user-2@company.com",
"manager": "manager-2@company.com"
},
"..."
] }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: [
{
user: 'user-1@company.com',
group_dimension: 'country',
group: 'france',
start_date: '2023-01',
end_date: '2023-10'
},
{user: 'user-2@company.com', manager: 'manager-2@company.com'},
'...'
]
})
};
fetch('https://api.qobra.co/v1/users/groups/bulk', 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.qobra.co/v1/users/groups/bulk",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
[
'user' => 'user-1@company.com',
'group_dimension' => 'country',
'group' => 'france',
'start_date' => '2023-01',
'end_date' => '2023-10'
],
[
'user' => 'user-2@company.com',
'manager' => 'manager-2@company.com'
],
'...'
]
]),
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.qobra.co/v1/users/groups/bulk"
payload := strings.NewReader("{\n \"data\": [\n {\n \"user\": \"user-1@company.com\",\n \"group_dimension\": \"country\",\n \"group\": \"france\",\n \"start_date\": \"2023-01\",\n \"end_date\": \"2023-10\"\n },\n {\n \"user\": \"user-2@company.com\",\n \"manager\": \"manager-2@company.com\"\n },\n \"...\"\n ]\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.qobra.co/v1/users/groups/bulk")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": [\n {\n \"user\": \"user-1@company.com\",\n \"group_dimension\": \"country\",\n \"group\": \"france\",\n \"start_date\": \"2023-01\",\n \"end_date\": \"2023-10\"\n },\n {\n \"user\": \"user-2@company.com\",\n \"manager\": \"manager-2@company.com\"\n },\n \"...\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.qobra.co/v1/users/groups/bulk")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": [\n {\n \"user\": \"user-1@company.com\",\n \"group_dimension\": \"country\",\n \"group\": \"france\",\n \"start_date\": \"2023-01\",\n \"end_date\": \"2023-10\"\n },\n {\n \"user\": \"user-2@company.com\",\n \"manager\": \"manager-2@company.com\"\n },\n \"...\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"count": "<Upserted manager relationships count>",
"data": [
{
"user": "user-1@company.com",
"group_dimension": "country",
"group": "france",
"start_date": "2023-01",
"end_date": "2023-10"
},
{
"user": "user@company.com",
"group_dimension": "country",
"group": "belgium",
"start_date": "2023-03",
"end_date": null
},
"..."
]
}{
"count": "<Errors count>",
"errors": [
{
"error": "NotFoundError",
"user": "user-3@company.com",
"resource": "group_dimension",
"description": "Group dimension not found for country"
},
{
"error": "NotFoundError",
"user": "user-4@company.com",
"resource": "group",
"description": "Group not found for france"
},
{
"error": "ParsingError",
"user": "user-test-4@company.com",
"resource": "<field_name>",
"description": "We had issues parsing the <field_name> provided : value <value_received>"
},
"..."
]
}Behavior
- Transaction: If one group attribution is not parsable, we raise you an error and import nothing. You have to fix your payload and send it to us again. And if the answer is a success, it means that every group attribution you sent us have been upserted
- Conflict Rule and upsert: Be careful, each user can only have one group by dimension for a given period. Given new attributions dates will override conflicting dates already present in Qobra. Also, if you send a payload with two groups attributions for the same user over the same period we’ll send you back an error.
- Limit: you can’t update more than 200 group attributions at a time.
- Error behavior: In case of any error, your group attributions wont be upserted
Authorizations
Body
application/json
The body contains the user data necessary to create a new user in Qobra
Show child attributes
Show child attributes
Was this page helpful?
⌘I