SDK API
  1. Request
SDK API
  • Request
    • Get or store user
      POST
    • Store visit event
      POST
    • Store event
      POST
    • Get campaign
      POST
    • Get strategy
      POST
    • Engagement
      GET
  1. Request

Get or store user

Developing
POST
/user
Регистрирует или обновляет пользователя в системе Gravity Field. Используется для инициализации SDK и формирования персонализированного контекста.
Возвращает UID, сегменты, условия и кампании, если они сработали в текущем контексте.

Request

Authorization
Provide your bearer token in the
Authorization
header when making requests to protected resources.
Example:
Authorization: Bearer ********************
Body Params application/json

Example
{
    "sec": "stringstringstringstring",
    "user": {
        "uid": "stringstringstringstring",
        "ses": "string",
        "attributes": {
            "property1": "string",
            "property2": "string"
        }
    },
    "ctx": {
        "type": "HOMEPAGE",
        "data": [
            "string"
        ],
        "lng": "string",
        "location": "string",
        "pageNumber": 0,
        "referrer": "string",
        "utm": {
            "utm_source": "string",
            "utm_medium": "string",
            "utm_campaign": "string",
            "utm_term": "string",
            "utm_content": "string"
        },
        "attributes": {
            "property1": "string",
            "property2": "string"
        }
    },
    "device": {
        "userTime": "2019-08-24T14:15:22Z",
        "ua": "string",
        "ip": "192.168.0.1",
        "id": "string",
        "tracking": "notDetermined",
        "permission": "provisional"
    },
    "options": {
        "isReturnCounter": false,
        "isReturnUserInfo": false
    }
}

Request Code Samples

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST '/user' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "sec": "stringstringstringstring",
    "user": {
        "uid": "stringstringstringstring",
        "ses": "string",
        "attributes": {
            "property1": "string",
            "property2": "string"
        }
    },
    "ctx": {
        "type": "HOMEPAGE",
        "data": [
            "string"
        ],
        "lng": "string",
        "location": "string",
        "pageNumber": 0,
        "referrer": "string",
        "utm": {
            "utm_source": "string",
            "utm_medium": "string",
            "utm_campaign": "string",
            "utm_term": "string",
            "utm_content": "string"
        },
        "attributes": {
            "property1": "string",
            "property2": "string"
        }
    },
    "device": {
        "userTime": "2019-08-24T14:15:22Z",
        "ua": "string",
        "ip": "192.168.0.1",
        "id": "string",
        "tracking": "notDetermined",
        "permission": "provisional"
    },
    "options": {
        "isReturnCounter": false,
        "isReturnUserInfo": false
    }
}'

Responses

🟢200Success
application/json
Body

Example
{
    "user": {
        "uid": "stringstringstringstring",
        "ses": "7356efc2-6ffd-4553-bade-b9ab5d9ce141",
        "segments": [
            "stringstringstringstring"
        ],
        "conditions": {
            "property1": {},
            "property2": {}
        },
        "details": {
            "slid": "string",
            "deviceInfo": {
                "brand": "string",
                "type": "desktop",
                "browser": "Chrome"
            },
            "trafficSource": "Paid Search",
            "geo": {
                "country": "string",
                "countryIso": "string",
                "region": "string",
                "regionIso": "string",
                "city": "string",
                "cityId": "string"
            },
            "isNew": true,
            "affinity": {
                "property1": {
                    "property1": 0,
                    "property2": 0
                },
                "property2": {
                    "property1": 0,
                    "property2": 0
                }
            }
        }
    },
    "campaigns": [
        {
            "campaignId": "stringstringstringstring",
            "experienceId": "stringstringstringstring",
            "trigger": "PAGELOAD"
        }
    ]
}
🟢204No Content
🟠403Forbidden
🟠422Parameter Error
🔴500Server Error
Modified at 2025-04-25 12:09:57
Next
Store visit event
Built with