Endpoint:

https://matchapi.peanutlabs.com/publisher/api/v1/profile/set

Basics

Base URL:

https://matchapi.peanutlabs.com/publisher/api/v1/profile/set

Protocol

HTTP/HTTPS

Method

POST

Content-Type

“application/json; charset=utf-8”

Response type

JSON

Auth

None

The Request Body

user_id

Dynata User ID (string)

pub_id

your App ID (integer)

iv

a cryptographically random initialization vector for the encrypted payload (string)

payload

(string) see section “The Payload” below

The value is a JSON object, serialized to string/bytes, padded to 128 bit blocksize, encrypted with AES CBC mode, and finally base64 encoded. More details on the encryption in section Encrypting the Payload. Since the payload is sent as part of the POST body, it does not need to be URL encoded.

Example Request Body

  "user_id": "avdempsey-1-91ae9381f1",
  "pub_id": 1,
  "iv": "8HO9Ew3VUUu8r7kuGjctdg==",
  "payload": "+f+GDKPo3P7nBtYcBqSGwHuNZCsL94SQe3EM+tL9ukcKhGx1bEpWOmJJZfottaDdWsx+tUZ3UBy35KOIY0dy8GU/HlVTPXzTodGKq2HaebLTSQTfIW9Z6hjlM4CS5rATI6P8HvZhVzsYTD/MMndL37KfD0DUBC/DbbPQqMhZ9BpYdeMsLk6A2vETeXnM2pxmjylhjpLZ/TcCZtrlk39nnEDfmxBG+UQR9nWt8cskTRXWbrcQpFccRS5x+/AhH7YVcQKaP0fcMLheyxj0KCI8lg=="
}

The Payload (Encrypted)

(string) The payload field in the request body is a JSON object, serialized to string/bytes, padded to 128 bit blocksize, encrypted with AES CBC mode, and finally base64 encoded. The JSON object has the following structure (description of fields following the example):

{
    "program_id": "points",
    "offers": True,
    "cpi": False,
    "user_ip": "4.35.165.126",
    "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Safari/604.1.38",
    "user_profile": {
        "dob": "1990-02-22",
        "sex": 1,
        "cc": "US",
        "postal": 94104,
            "profile_data": {
            "q157": ["qx157-01"],
            ... // Other Peanut Labs targeting attributes
        }
    }
}

program_id

(optional, string) only applicable if your application is configured with multiple virtual currency reward programs. If omitted, the default virtual currency configured for your application will be used (99% of our partners). If you do have multiple virtual currency reward programs set up, pass the ID of the program for the API to use this currency when matching surveys and formatting results. The API will return surveys with the user reward in terms of this program’s virtual currency.

offers

(optional, string) only applicable if you want to return a list of Offers in the response for any given user. Set the field to True to include Offers. Otherwise, set the field to False or omit this key-value pair entirely.

cpi

(optional, string) only applicable if you want to include CPI for each Offers result. Set the field to True to include CPI. Otherwise, set the field to False or omit this key-value pair entirely.

user_ip

(required, string) the IP address of the end-user for whom the API request is being made. A user’s IP address is used for geographic survey targeting, as well as other eligibility and security checks. Since the API call can be made server-to-server (as opposed to originating from the user’s browser) we can’t rely on the IP address of the request. This is the only mandatory field in the payload.

user_agent

(required, string) the user_agent of the end-user’s browser. We use this to help tailor matches for browser, operating system, and device compatibility. Projects with device targeting will not be included in match results if no user_agent is provided.

user_profile

(optional for returning users, mandatory for new users, JSON) the user_profile field is the same object as described in the Sending user profiles section of the Integration Guide (with the exception that the user_id field is optional, since user_id is also included in the top-level of the request body). The right hand column of that page shows an example from creating the object, to performing the encryption.

Important Note:

The encryption step described here applies to the entire payload parameter in the request body, not just the user-Profile parameter.

On each request to the API that includes a user_profile, the user’s profile in PL will be updated before performing the survey matching process. First time users will be created in the PL system; an error will be returned if no profile was provided for first time users. In practice, you can include the profile in the encrypted payload on each request.

Successful Response

{
    "user_id": "avdempsey-1-91ae9381f1-10090-82463a0bd1"
}