Запрос кампаний

Для получения кампании из API Gravity Field необходимо отправить запрос в endpoint choose. В запросе должен быть указан селектор кампании, который вы задали при создании кампании.

В случае гибридной интеграции возможно использовать choose-запрос с пустым селектором для получения актуальных значений user.slid и session.sl

post

Get the chosen variations for one or more campaigns.

Authorizations
Body
userobjectrequired

User ID. A Gravity Field-generated identifier is used, and managed via cookies. For a new user, send this object empty.

sessionobjectrequired

Session ID. A Gravity Field-generated identifier is used. For new sessions, send this object empty.

contextobjectrequired

The request's context.

selectorobjectrequired

Campaigns to choose variations for.

optionsobjectoptional

Request configuration parameters.

Responses
post
curl -L \
  --request POST \
  --url 'https://evs.gravityfield.ai/ssapi/choose' \
  --header 'Authorization: Bearer API-KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "user": {
      "id": "100"
    },
    "session": {
      "custom": "custom_session_100"
    },
    "context": {
      "page": {
        "type": "PRODUCT",
        "data": [
          "sku_1"
        ],
        "location": "https://test.ru/product/sku_1"
      },
      "device": {
        "userAgent": "Mozilla/5.0 ...",
        "ip": "8.8.8.8"
      }
    },
    "selector": {
      "names": [
        "test_selector"
      ]
    }
  }'
{
  "choices": [
    {
      "name": "test recs campaign",
      "type": "RECS_DECISION",
      "decisionId": "unique token",
      "variations": {
        "name": "variation A",
        "payload": {
          "type": "RECS",
          "data": {
            "slots": [
              {
                "sku": "sku_1",
                "productData": {
                  "categories": [
                    "a",
                    "b"
                  ],
                  "price": 100
                },
                "slotId": "unique slot token"
              },
              {
                "sku": "sku_2",
                "productData": {
                  "categories": [
                    "a",
                    "b"
                  ],
                  "price": 200
                },
                "slotId": "unique slot token"
              }
            ]
          }
        }
      }
    }
  ]
}

Last updated

Was this helpful?