Batch Request
Batch Request
POST
https://api.ocamba.com/v2/ocamba/batch
Batch request allows you to execute multiple API requests in a single HTTP call. Each call within the batch is referred to as a subrequest, and the container object is the main request. By default, all subrequests are processed in parallel. Set mode to serial to process them sequentially.
Tip
Use batch requests to reduce network overhead when you need to perform multiple independent API operations.
Note
Response handling: A response code of 200 means the main request was well-formed. Each subrequest may have succeeded or failed independently. Subresponses appear in the same order as the corresponding subrequests.
Abort on fail: Used only for serial batch requests. Set abort_on_fail to true on a subrequest to skip all remaining requests after first failure.
Warning
Limitations: Maximum 50 subrequests per batch. Each subrequest is counted separately for rate limiting. Server limitations apply to request body size, URL size, and header size.
Rate limits:
- Burst: 10/s
- Steady: 150/m
Request schema
bodyResponse schemas
›
200
application/json
›
400
application/json
›
500
application/json
curl -X POST \
"https://api.ocamba.com/v2/ocamba/batch" \
-H "Authorization: Bearer {TOKEN}" \
-H "Content-Type: application/json" \
-d '[
{
"method": "GET",
"relative_url": "/members/10"
},
{
"method": "GET",
"relative_url": "members/10/roles"
}
]'const url = 'https://api.ocamba.com/v2/ocamba/batch';
const options = {
method: 'POST',
headers: {
Authorization: "Bearer {TOKEN}",
'Content-Type': "application/json"
},
body: JSON.stringify(
[
{
"method": "GET",
"relative_url": "/members/10"
},
{
"method": "GET",
"relative_url": "members/10/roles"
}
]
)
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}$ch = curl_init("https://api.ocamba.com/v2/ocamba/batch");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer {TOKEN}",
"Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(
[
[
"method" => "GET",
"relative_url" => "/members/10"
],
[
"method" => "GET",
"relative_url" => "members/10/roles"
]
]
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);curl -X POST \
"https://api.ocamba.com/v2/ocamba/batch" \
-H "Authorization: Bearer {TOKEN}" \
-H "Content-Type: application/json" \
-d '[
{
"method": "POST",
"relative_url": "/roles",
"body": {
"name": "viewer_new",
"permissions": [
"members.get",
"roles.get",
"countries.get",
"languages.get"
]
}
},
{
"method": "DELETE",
"relative_url": "/roles/viewer"
}
]'const url = 'https://api.ocamba.com/v2/ocamba/batch';
const options = {
method: 'POST',
headers: {
Authorization: "Bearer {TOKEN}",
'Content-Type': "application/json"
},
body: JSON.stringify(
[
{
"method": "POST",
"relative_url": "/roles",
"body": {
"name": "viewer_new",
"permissions": [
"members.get",
"roles.get",
"countries.get",
"languages.get"
]
}
},
{
"method": "DELETE",
"relative_url": "/roles/viewer"
}
]
)
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}$ch = curl_init("https://api.ocamba.com/v2/ocamba/batch");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer {TOKEN}",
"Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(
[
[
"method" => "POST",
"relative_url" => "/roles",
"body" => [
"name" => "viewer_new",
"permissions" => [
"members.get",
"roles.get",
"countries.get",
"languages.get"
]
]
],
[
"method" => "DELETE",
"relative_url" => "/roles/viewer"
]
]
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);curl -X POST \
"https://api.ocamba.com/v2/ocamba/batch" \
-H "Authorization: Bearer {TOKEN}" \
-H "Content-Type: application/json" \
-d '[
{
"method": "POST",
"relative_url": "/roles",
"body": {
"name": "viewer_new",
"permissions": [
"members.get",
"roles.get",
"countries.get",
"languages.get"
]
},
"abort_on_fail": true
},
{
"method": "DELETE",
"relative_url": "/roles/viewer"
}
]'const url = 'https://api.ocamba.com/v2/ocamba/batch';
const options = {
method: 'POST',
headers: {
Authorization: "Bearer {TOKEN}",
'Content-Type': "application/json"
},
body: JSON.stringify(
[
{
"method": "POST",
"relative_url": "/roles",
"body": {
"name": "viewer_new",
"permissions": [
"members.get",
"roles.get",
"countries.get",
"languages.get"
]
},
"abort_on_fail": true
},
{
"method": "DELETE",
"relative_url": "/roles/viewer"
}
]
)
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}$ch = curl_init("https://api.ocamba.com/v2/ocamba/batch");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer {TOKEN}",
"Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(
[
[
"method" => "POST",
"relative_url" => "/roles",
"body" => [
"name" => "viewer_new",
"permissions" => [
"members.get",
"roles.get",
"countries.get",
"languages.get"
]
],
"abort_on_fail" => true
],
[
"method" => "DELETE",
"relative_url" => "/roles/viewer"
]
]
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);curl -X POST \
"https://api.ocamba.com/v2/ocamba/batch" \
-H "Authorization: Bearer {TOKEN}" \
-H "Content-Type: application/json" \
-d '[
{
"method": "POST",
"relative_url": "/roles",
"body": {
"name": "viewer_new",
"permissions": [
"members.get",
"roles.get",
"countries.get",
"languages.get"
]
}
},
{
"method": "DELETE",
"relative_url": "/roles/viewer",
"headers": {
"force-delete": "yes"
}
}
]'const url = 'https://api.ocamba.com/v2/ocamba/batch';
const options = {
method: 'POST',
headers: {
Authorization: "Bearer {TOKEN}",
'Content-Type': "application/json"
},
body: JSON.stringify(
[
{
"method": "POST",
"relative_url": "/roles",
"body": {
"name": "viewer_new",
"permissions": [
"members.get",
"roles.get",
"countries.get",
"languages.get"
]
}
},
{
"method": "DELETE",
"relative_url": "/roles/viewer",
"headers": {
"force-delete": "yes"
}
}
]
)
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}$ch = curl_init("https://api.ocamba.com/v2/ocamba/batch");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer {TOKEN}",
"Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(
[
[
"method" => "POST",
"relative_url" => "/roles",
"body" => [
"name" => "viewer_new",
"permissions" => [
"members.get",
"roles.get",
"countries.get",
"languages.get"
]
]
],
[
"method" => "DELETE",
"relative_url" => "/roles/viewer",
"headers" => [
"force-delete" => "yes"
]
]
]
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);Responses
200 OK
{
"total_counter": 10,
"success_counter": 10,
"parts": [
{
"code": 200
}
]
}
400 Bad Request
{
"code": 400,
"title": "Bad request.",
"message": "The request body is not valid.",
"trace_id": "99a84211-f73d-4ff8-acdf-eb3e06bb9d62"
}
500 Internal Server Error
{
"code": 500,
"title": "Internal server error.",
"message": "Internal server error."
}
Responses