Update a quota (V1)
Replace the V1 quota criteria for a project. Send version and criteria. Target counts are recalculated from the project’s number of participants.
curl --request PATCH \
--url https://api-staging.respondent.io/v1/projects/{projectId}/quota \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--header 'x-api-secret: <x-api-secret>' \
--data '
{
"criteria": {
"category": "gender",
"segments": [
{
"value": "male",
"percentage": 50
}
]
},
"version": "v1"
}
'import requests
url = "https://api-staging.respondent.io/v1/projects/{projectId}/quota"
payload = {
"criteria": {
"category": "gender",
"segments": [
{
"value": "male",
"percentage": 50
}
]
},
"version": "v1"
}
headers = {
"x-api-key": "<x-api-key>",
"x-api-secret": "<x-api-secret>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {
'x-api-key': '<x-api-key>',
'x-api-secret': '<x-api-secret>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
criteria: {category: 'gender', segments: [{value: 'male', percentage: 50}]},
version: 'v1'
})
};
fetch('https://api-staging.respondent.io/v1/projects/{projectId}/quota', 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-staging.respondent.io/v1/projects/{projectId}/quota",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'criteria' => [
'category' => 'gender',
'segments' => [
[
'value' => 'male',
'percentage' => 50
]
]
],
'version' => 'v1'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <x-api-key>",
"x-api-secret: <x-api-secret>"
],
]);
$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-staging.respondent.io/v1/projects/{projectId}/quota"
payload := strings.NewReader("{\n \"criteria\": {\n \"category\": \"gender\",\n \"segments\": [\n {\n \"value\": \"male\",\n \"percentage\": 50\n }\n ]\n },\n \"version\": \"v1\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("x-api-key", "<x-api-key>")
req.Header.Add("x-api-secret", "<x-api-secret>")
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.patch("https://api-staging.respondent.io/v1/projects/{projectId}/quota")
.header("x-api-key", "<x-api-key>")
.header("x-api-secret", "<x-api-secret>")
.header("Content-Type", "application/json")
.body("{\n \"criteria\": {\n \"category\": \"gender\",\n \"segments\": [\n {\n \"value\": \"male\",\n \"percentage\": 50\n }\n ]\n },\n \"version\": \"v1\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-staging.respondent.io/v1/projects/{projectId}/quota")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["x-api-key"] = '<x-api-key>'
request["x-api-secret"] = '<x-api-secret>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"criteria\": {\n \"category\": \"gender\",\n \"segments\": [\n {\n \"value\": \"male\",\n \"percentage\": 50\n }\n ]\n },\n \"version\": \"v1\"\n}"
response = http.request(request)
puts response.read_body{
"progress": {
"1": {
"currentCount": 10,
"targetCount": 25
},
"2": {
"currentCount": 15,
"targetCount": 30
}
},
"id": "<string>",
"projectId": "<string>",
"version": "v1",
"totalTarget": 2,
"status": "IN_PROGRESS",
"criteria": {
"category": "gender",
"segments": [
{
"value": "male",
"percentage": 50,
"id": "1"
}
]
},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}PATCH /v1/projects/{projectId}/quota replaces criteria and returns 200 with the V1 body. The request has the same shape as Create a quota (V1). A project with no V1 quota returns 404.Path Parameters
Body
Updated quota criteria details
Hide child attributes
Hide child attributes
The category this quota applies to
age, gender, ethnicity, location "gender"
Array of quota segments. Must contain at least one segment.
Hide child attributes
Hide child attributes
The value for this segment (e.g., "Male" for gender, "18-24" for age, "USA" for location). Type depends on category.
male, female, other, nonbinary, transmale, transfemale, prefernottoanswer, 18-20, 21-29, 30-39, 40-54, 55+, americanindianalaskannative, hispaniclatino, blackorafricanamerican, asianpacificislander, whitecaucasian, middleeastern, multipleethnicity, prefernotdisclose, AX, AL, DZ, AS, AD, AI, AQ, AG, AR, AM, AW, AU, AT, BS, BH, BD, BB, BY, BE, BZ, BJ, BM, BT, BO, BA, BW, BV, BR, VG, IO, BN, BG, BF, BI, CV, CM, CA, KY, CF, TD, CL, CX, CC, CO, KM, CG, CK, CR, HR, CU, CW, CY, CZ, CI, CD, DK, DJ, DM, EC, EG, SV, GQ, ER, EE, SZ, ET, FK, FO, FJ, FI, FR, GF, PF, TF, GA, GM, GE, DE, GI, GR, GL, GD, GP, GU, GT, GG, GN, GW, GY, HT, HM, VA, HN, HK, HU, IS, IN, ID, IR, IQ, IE, IM, IL, IT, JM, JP, JE, JO, KZ, KE, KI, LA, LV, LB, LR, LY, LI, LT, LU, MG, MW, MY, MV, ML, MT, MH, MQ, MR, MU, YT, MX, FM, MD, MC, MN, ME, MS, MA, MZ, NA, NR, NP, NL, NC, NZ, NI, NE, NU, NF, KP, MK, MP, NO, OM, PW, PA, PG, PY, PE, PH, PN, PL, PT, PR, QA, RO, RW, RE, SH, KN, LC, PM, VC, WS, SM, ST, SA, RS, SC, SL, SG, SK, SI, SB, SO, ZA, GS, KR, ES, LK, SR, SJ, SE, CH, TZ, TW, TH, TL, TG, TK, TO, TT, TN, TR, TM, TC, TV, VI, UG, AE, GB, UM, US, UY, VU, VE, VN, WF, EH, ZM, ZW, all "male"
The target percentage for this segment (0-100)
0 <= x <= 10050
Version of the quota
v1 "v1"
Response
Quota progress by segment ID
{
"1": { "currentCount": 10, "targetCount": 25 },
"2": { "currentCount": 15, "targetCount": 30 }
}
v1 x >= 1IN_PROGRESS, FILLED Hide child attributes
Hide child attributes
The category this quota applies to
age, gender, ethnicity, location "gender"
Array of quota segments
Hide child attributes
Hide child attributes
The value for this segment (e.g., "Male" for gender, "18-24" for age, "USA" for location). Type depends on category.
male, female, other, nonbinary, transmale, transfemale, prefernottoanswer, 18-20, 21-29, 30-39, 40-54, 55+, americanindianalaskannative, hispaniclatino, blackorafricanamerican, asianpacificislander, whitecaucasian, middleeastern, multipleethnicity, prefernotdisclose, AX, AL, DZ, AS, AD, AI, AQ, AG, AR, AM, AW, AU, AT, BS, BH, BD, BB, BY, BE, BZ, BJ, BM, BT, BO, BA, BW, BV, BR, VG, IO, BN, BG, BF, BI, CV, CM, CA, KY, CF, TD, CL, CX, CC, CO, KM, CG, CK, CR, HR, CU, CW, CY, CZ, CI, CD, DK, DJ, DM, EC, EG, SV, GQ, ER, EE, SZ, ET, FK, FO, FJ, FI, FR, GF, PF, TF, GA, GM, GE, DE, GI, GR, GL, GD, GP, GU, GT, GG, GN, GW, GY, HT, HM, VA, HN, HK, HU, IS, IN, ID, IR, IQ, IE, IM, IL, IT, JM, JP, JE, JO, KZ, KE, KI, LA, LV, LB, LR, LY, LI, LT, LU, MG, MW, MY, MV, ML, MT, MH, MQ, MR, MU, YT, MX, FM, MD, MC, MN, ME, MS, MA, MZ, NA, NR, NP, NL, NC, NZ, NI, NE, NU, NF, KP, MK, MP, NO, OM, PW, PA, PG, PY, PE, PH, PN, PL, PT, PR, QA, RO, RW, RE, SH, KN, LC, PM, VC, WS, SM, ST, SA, RS, SC, SL, SG, SK, SI, SB, SO, ZA, GS, KR, ES, LK, SR, SJ, SE, CH, TZ, TW, TH, TL, TG, TK, TO, TT, TN, TR, TM, TC, TV, VI, UG, AE, GB, UM, US, UY, VU, VE, VN, WF, EH, ZM, ZW, all "male"
The target percentage for this segment (0-100)
0 <= x <= 10050
Unique identifier for the segment
"1"
curl --request PATCH \
--url https://api-staging.respondent.io/v1/projects/{projectId}/quota \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--header 'x-api-secret: <x-api-secret>' \
--data '
{
"criteria": {
"category": "gender",
"segments": [
{
"value": "male",
"percentage": 50
}
]
},
"version": "v1"
}
'import requests
url = "https://api-staging.respondent.io/v1/projects/{projectId}/quota"
payload = {
"criteria": {
"category": "gender",
"segments": [
{
"value": "male",
"percentage": 50
}
]
},
"version": "v1"
}
headers = {
"x-api-key": "<x-api-key>",
"x-api-secret": "<x-api-secret>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {
'x-api-key': '<x-api-key>',
'x-api-secret': '<x-api-secret>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
criteria: {category: 'gender', segments: [{value: 'male', percentage: 50}]},
version: 'v1'
})
};
fetch('https://api-staging.respondent.io/v1/projects/{projectId}/quota', 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-staging.respondent.io/v1/projects/{projectId}/quota",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'criteria' => [
'category' => 'gender',
'segments' => [
[
'value' => 'male',
'percentage' => 50
]
]
],
'version' => 'v1'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <x-api-key>",
"x-api-secret: <x-api-secret>"
],
]);
$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-staging.respondent.io/v1/projects/{projectId}/quota"
payload := strings.NewReader("{\n \"criteria\": {\n \"category\": \"gender\",\n \"segments\": [\n {\n \"value\": \"male\",\n \"percentage\": 50\n }\n ]\n },\n \"version\": \"v1\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("x-api-key", "<x-api-key>")
req.Header.Add("x-api-secret", "<x-api-secret>")
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.patch("https://api-staging.respondent.io/v1/projects/{projectId}/quota")
.header("x-api-key", "<x-api-key>")
.header("x-api-secret", "<x-api-secret>")
.header("Content-Type", "application/json")
.body("{\n \"criteria\": {\n \"category\": \"gender\",\n \"segments\": [\n {\n \"value\": \"male\",\n \"percentage\": 50\n }\n ]\n },\n \"version\": \"v1\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-staging.respondent.io/v1/projects/{projectId}/quota")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["x-api-key"] = '<x-api-key>'
request["x-api-secret"] = '<x-api-secret>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"criteria\": {\n \"category\": \"gender\",\n \"segments\": [\n {\n \"value\": \"male\",\n \"percentage\": 50\n }\n ]\n },\n \"version\": \"v1\"\n}"
response = http.request(request)
puts response.read_body{
"progress": {
"1": {
"currentCount": 10,
"targetCount": 25
},
"2": {
"currentCount": 15,
"targetCount": 30
}
},
"id": "<string>",
"projectId": "<string>",
"version": "v1",
"totalTarget": 2,
"status": "IN_PROGRESS",
"criteria": {
"category": "gender",
"segments": [
{
"value": "male",
"percentage": 50,
"id": "1"
}
]
},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}