Archive users bulk
curl --request DELETE \
--url https://api.qobra.co/v1/users/archive/bulk \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"data": [
{
"user": "user-1@company.com",
"end_date": "2023-10"
},
{
"user": "user-2@company.com"
},
"..."
]
}
'import requests
url = "https://api.qobra.co/v1/users/archive/bulk"
payload = { "data": [{
"user": "user-1@company.com",
"end_date": "2023-10"
}, { "user": "user-2@company.com" }, "..."] }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.delete(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: [
{user: 'user-1@company.com', end_date: '2023-10'},
{user: 'user-2@company.com'},
'...'
]
})
};
fetch('https://api.qobra.co/v1/users/archive/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/archive/bulk",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
[
'user' => 'user-1@company.com',
'end_date' => '2023-10'
],
[
'user' => 'user-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/archive/bulk"
payload := strings.NewReader("{\n \"data\": [\n {\n \"user\": \"user-1@company.com\",\n \"end_date\": \"2023-10\"\n },\n {\n \"user\": \"user-2@company.com\"\n },\n \"...\"\n ]\n}")
req, _ := http.NewRequest("DELETE", 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.delete("https://api.qobra.co/v1/users/archive/bulk")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": [\n {\n \"user\": \"user-1@company.com\",\n \"end_date\": \"2023-10\"\n },\n {\n \"user\": \"user-2@company.com\"\n },\n \"...\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.qobra.co/v1/users/archive/bulk")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.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 \"end_date\": \"2023-10\"\n },\n {\n \"user\": \"user-2@company.com\"\n },\n \"...\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"message": "users archived successfully"
}{
"count": "<Errors count>",
"errors": [
{
"error": "NotFoundError",
"resource": "user",
"description": "User not found for email john.doe@qobra.co"
},
{
"error": "ValidationError",
"resource": "end_date",
"description": "Invalid date format, '2024-07-01' doesn't match the YYYY-MM format"
}
]
}User management
Archive users bulk
Archive users in bulk.
DELETE
/
v1
/
users
/
archive
/
bulk
Archive users bulk
curl --request DELETE \
--url https://api.qobra.co/v1/users/archive/bulk \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"data": [
{
"user": "user-1@company.com",
"end_date": "2023-10"
},
{
"user": "user-2@company.com"
},
"..."
]
}
'import requests
url = "https://api.qobra.co/v1/users/archive/bulk"
payload = { "data": [{
"user": "user-1@company.com",
"end_date": "2023-10"
}, { "user": "user-2@company.com" }, "..."] }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.delete(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: [
{user: 'user-1@company.com', end_date: '2023-10'},
{user: 'user-2@company.com'},
'...'
]
})
};
fetch('https://api.qobra.co/v1/users/archive/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/archive/bulk",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
[
'user' => 'user-1@company.com',
'end_date' => '2023-10'
],
[
'user' => 'user-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/archive/bulk"
payload := strings.NewReader("{\n \"data\": [\n {\n \"user\": \"user-1@company.com\",\n \"end_date\": \"2023-10\"\n },\n {\n \"user\": \"user-2@company.com\"\n },\n \"...\"\n ]\n}")
req, _ := http.NewRequest("DELETE", 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.delete("https://api.qobra.co/v1/users/archive/bulk")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": [\n {\n \"user\": \"user-1@company.com\",\n \"end_date\": \"2023-10\"\n },\n {\n \"user\": \"user-2@company.com\"\n },\n \"...\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.qobra.co/v1/users/archive/bulk")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.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 \"end_date\": \"2023-10\"\n },\n {\n \"user\": \"user-2@company.com\"\n },\n \"...\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"message": "users archived successfully"
}{
"count": "<Errors count>",
"errors": [
{
"error": "NotFoundError",
"resource": "user",
"description": "User not found for email john.doe@qobra.co"
},
{
"error": "ValidationError",
"resource": "end_date",
"description": "Invalid date format, '2024-07-01' doesn't match the YYYY-MM format"
}
]
}Behavior
- Transaction: If one part of the payload is not parsable (or understandable by the system), we raise you an error and we don’t archive anyone from the payload. You have to fix your payload and send it to us again. And if the answer is a success, it means that every user to archive you sent us have been archived successfully
- Conflict Rule and archive: If you try to archive a user that is managing someone on the given archive period, we raise you an error.
- Limit: you can’t archive more than 50 users at a time.
- Error behavior: In case of any error, your user wont be archived
Was this page helpful?
⌘I