Target API
Target types
GET /api/targettypes
Possible response:
[
{
"id": 2,
"name": "gender",
"editable": false
},
{
"id": 9,
"name": "brand",
"editable": true
},
{
"id": 12,
"name": "interest",
"editable": true
}
...
]
For a specific target type:
GET /api/targettypes/12
Possible response:
{
"id": 12,
"name": "interest",
"editable": true
}
Target values
GET
To get all target values for a specific type:
GET /api/targettypes/12/targets?filterActive=false
filterActive is an optional parameter with default value true. It controls whether the response will contain inactive results.
Possible response:
[
{
"id": 1,
"name": "Bossaball",
"code": "bossaball",
"active": true
},
{
"id": 2,
"name": "Kazoo clubs",
"code": "!kazooclubs",
"active": false
},
{
"id": 3,
"name": "Belgian waffles",
"code": "bestwaffles",
"active": true
},
...
]
To get a specific target value:
GET /api/targettypes/12/targets/3
{
"id": 3,
"name": "Belgian waffles",
"code": "bestwaffles",
"active": true
}
POST
To add a new target value, the target type must be editable.
POST /api/targettypes/{typeId}/targets
With possible body:
{
"name": "Belgian waffles",
"code": "bestwaffles",
"active": true
}
Possible response:
{
"id": 3,
"name": "Belgian waffles",
"code": "bestwaffles",
"active": true
}
The field code must contain only alphanumeric characters, underscores and capitals. The first character can optionally be an exclamation mark to denote a negative targeting field.
No duplicate codes are allowed (per target type).
See Negative Targeting for more information.
PUT
To update a target value:
PUT /api/targettypes/12/targets
PUT /api/targettypes/12/targets/3
With possible body:
{
"id": 3,
"name": "Belgian waffles",
"active": false
}
Specifying the id at the end of the URL is optional. The only fields that are allowed to change are name and active. All other fields are ignored.
Returns OK.
There are no delete semantics because of logging reasons. Deactivate the target values instead.
Logging
To request the edit logs for all targets:
GET /api/targettypes/log?start=0&size=100
Logging results are sorted from newest to oldest. Only the results in [start, start+size[ are returned.
size is an obligatory parameter, start defaults to 0.
Possible result:
[
{
"id": 36131,
"logAction": "INSERT_TARGET_VALUE",
"source": "API",
"parameters": "{\"typeId\"=12, \"body\"={\"id\":1,\"name\":\"Bossaball\",\"code\":\"bossaball\",\"active\":true}}",
"userId": 143,
"timestamp": 1540304089000,
"userName": "Adhese Admin"
},
{
"id": 36130,
"logAction": "UPDATE_TARGET_VALUE",
"source": "API",
"parameters": "{\"typeId\"=12, \"body\"={\"id\":2,\"name\":\"Kazoo clubs\",\"active\":false}}",
"userId": 143,
"timestamp": 1540304044000,
"userName": "Adhese Admin"
},
{
"id": 36129,
"logAction": "UPDATE_TARGET_VALUE",
"source": "API",
"parameters": "{\"typeId\"=12, \"body\"={\"id\":3,\"name\":\"Belgian waffles\",\"code\":\"bestwaffles\",\"active\":true}}",
"userId": 143,
"timestamp": 1540304017000,
"userName": "Adhese Admin"
},
...
]
The timestamp is the time since the UNIX Epoch in milliseconds.
No Comments