Request examples

Here's a sample request. The context is a Product Details Page (PDP) in an imaginary
e-commerce website, at sugoi-ne.com:

Calling Choose with cURL

curl --request POST  
  --url <https://dy-api.com/v2/serve/user/choose>  
  --header 'content-type: application/json'  
  --header 'DY-API-Key: baadc6ba740a352c9106dc7857a7eb9c'  
  --data '{  
      "user": {  
        "dyid": "-4350463893986789401",  
        "dyid_server": "-4350463893986789401"  
      },  
      "session": { "dy": "ohyr6v42l9zd4bpinnvp7urjjx9lrssw" },  
      "selector": { "names": ["PDP Top Banner", "PDP Recs"] },  
      "context": {  
        "page": {  
          "type": "PRODUCT",  
          "data": ["7383723-010"],  
          "location": "<https://sugoi-ne.com/men-pants/p7383723-010">,  
          "referrer": "<https://sugoi-ne.com/men-pants">,  
          "locale": "en_US"  
        },  
        "device": {  
          "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",  
          "ip": "54.100.200.255"  
        },  
        "pageAttributes": { "customPageAttribute": "someValue" }  
      },  
      "options": { "isImplicitPageview": false }
}'

Calling Choose with cURL (API section type)

curl --request POST  
  --url <https://dy-api.com/v2/serve/user/choose>  
  --header 'content-type: application/json'  
  --header 'DY-API-Key: baadc6ba740a352c9106dc7857a7eb9c'  
  --data '{  
      "user": { "id": "yaexono4ohphania" },  
      "session": { "custom": "iquahngaishe2koh" },  
      "selector": { "names": ["PDP Top Banner", "PDP Recs"] },  
      "context": {  
        "page": {  
          "type": "PRODUCT",  
          "data": ["7383723-010"],  
          "location": "<https://sugoi-ne.com/men-pants/p7383723-010">,  
          "referrer": "<https://sugoi-ne.com/men-pants">,  
          "locale": "en_US"  
        },  
        "device": {  
          "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",  
          "ip": "54.100.200.255"  
        },  
        "pageAttributes": { "customPageAttribute": "someValue" }  
      },  
      "options": { "isImplicitPageview": true }
}'

Response examples

Response body

{  
  "choices": [  
    {  
      "id": 5,  
      "name": "PDP Top Banner",  
      "type": "DECISION",  
      "decisionId": "aGVsbG8K",  
      "variations": [  
        {  
          "id": 52,  
          "payload": {  
            "type": "CUSTOM_JSON",  
            "data": {  
              "key1": "value1",  
              "key2": "value2"  
            }  
          }  
        }  
      ]  
    },  
    {  
      "id": 24,  
      "name": "PDP Recs",  
      "type": "RECS_DECISION",  
      "decisionId": "d29ybGQK",  
      "variations": [  
        {  
          "id": 203,  
          "payload": {  
            "type": "RECS",  
            "data": {  
              "slots": [  
                {  
                  "slotId": "aGVsbG93b3JsZAo=",  
                  "sku": "6323723",  
                  "productData": {  
                    "name": "Plaid shirt",  
                    "price": 39.99,  
                    "url": "https://website.com/men-pants/p6323723-020"  
                  }  
                },  
                {  
                  "slotId": "d2VsY29tZWR1ZAo=",  
                  "sku": "5413764",  
                  "productData": {  
                    "name": "Khaki pants",  
                    "price": 59.99,  
                    "url": "https://website.com/men-pants/p5413764-010"  
                  }  
                }  
              ]  
            }  
          }  
        }  
      ]  
    }  
  ]  
}

Response body – control group

{
  "choices": [
    {
      "id": 652700,
      "name": "demoBanner",
      "type": "DECISION",
      "variations": [],
      "groups": [
        "demo"
      ],
      "decisionId": "mbQtNDMxOTQxODU1MTU3ODI0MjY2Ms4AGKErqDEyNjkyNjU4AJECkc4BsFonpTQ1OTg4wMA="
    }
  ],
  "cookies": [
    {
      "name": "_dyid_server",
      "value": "7282320792394869879",
      "maxAge": "31556926"
    },
    {
      "name": "_dyjsession",
      "value": "e3xi77qrxbsxxxmi18d8kxek6tdd12qj",
      "maxAge": "1800"
    }
  ]
}