In some cases, you may desire to set up a QBP survey as per UI.

This can be accomplished using the QBP API.

The QBP feature must be enabled from an operator to use this API

Request


POST $apihost/$basepath/buyers/v2/surveys

($apihost is the environment against which you are testing, and $basepath is the base path with the api version. All Buy API calls will require access-token parameter in the header) 

Request Payload when QBP is Enable:

{
  "qbp" : {
    "enable": true,
    "quota_ids": [
      "abc", // buyer_quota_id
      "xyz"
    ]
    "category": "Age" // optional in case of UI.
  }
}

Request Payload when QBP is Disable:

{
  "qbp" : {
    "enable": false
  }
}

Example:

POST $apihost/$basepath/buyers/v2/surveys

Body: 

{
    "live_url": "http://b_emulator.purespectrum.net:3000/emulated_surveyss",
    "test_url": "http://b_emulator.purespectrum.net:3000/emulated_surveyss",
    "survey_title": "test api ",
    "survey_category_code": 231,
    "survey_localization": "en_US",
    "completes_required": 100,
    "expected_ir": 10,
    "expected_loi": 10,
    "offer_price": 10,
    "field_time": 99,
     "qbp": {
        "enable": true,
        "quota_ids": [
            "M","F"
        ]},
     "quotas": [
        {
            "buyer_quota_id": "M",
            "required_count": 50,
            "criteria": [
                {
                    "qualification_code": 211,
                    "condition_codes": [
                        "111"
                    ]
                }
            ]
        },
        {
            "buyer_quota_id": "F",
            "required_count": 50,
            "criteria": [
                {
                    "qualification_code": 211,
                    "condition_codes": [
                        "112"
                    ]
                }
            ]
        }
    ],
    "qualifications": [
        {
            "condition_codes": [
                "111",
                "112"
            ],
            "qualification_code": 211
        },
        {
            "range_sets": [
                {
                    "from": 18,
                    "to": 99,
                    "units": 311
                }
            ],
            "qualification_code": 212
        }
    ]}


Result 


Error 1:

QBP can’t be enabled without quotas.

Error Message 1:

{
    "ps_api_response_code": 1007,
    "ps_api_response_message": "QBP can be enabled with quotas only."
}

Error 2:

QBP quotas can’t be enabled after getting the survey live, User can only change it in the draft survey.

Error Message 2:

{
    "ps_api_response_code": 1007,
    "api_response_message": "QBP changes are allowed in draft surveys only."
}