Adobe  I/O

Adobe Target

Design

A design is a script (velocity template) that can be used to render recommendations. See the parent page for common documentation that applies to all resources within the API.

List designs

GET /recs/{client}/designs
List all available designs.
RETURN TYPE
RESPONSES
200 OK
400 Bad Request. Most probably the data provided in the request is invalid.
401 The user is not allowed to perform this operation.
403 Access to this resource is forbidden.
404 The referenced resource was not found.
PARAMETERS
offset (optional) Query Parameter — integer
limit (optional) Query Parameter — integer
references (optional) Query Parameter — boolean
includeScript (optional) Query Parameter — boolean

Sample code

curl -X GET -H "Accept: application/vnd.adobe.target.v1+json" -H "X-Target-user-email: buzz@adobe.com" https://{recs-host}/api/recs/demo/designs?offset=1&limit=6&references=true

[
  {
    "name":"name","id":2,"script":"body --> $entity1.id",
    "references": {
      "recommendations": {
      "activeCount": 1,
      "inactiveCount": 0
      },
       "recommendationUnits":{
        "count":1
      }
    }
   },
  {"name":"name2","id":3,"script":"body2 --> $entity1.name", "references":[...]
...
]

Create a design

POST /recs/{client}/designs
Create a new design.
REQUEST BODY
design (required) Body Parameter — Design
RESPONSES
201 Created
400 Bad Request. Most probably the data provided in the request is invalid.
401 The user is not allowed to perform this operation.
403 Access to this resource is forbidden.
404 The referenced resource was not found.

Sample code

curl -X POST -H "Accept: application/vnd.adobe.target.v1+json" -H "Content-Type: application/vnd.adobe.target.v1+json" -H "X-Target-user-email: buzz@adobe.com" https://{recs-host}/api/recs/demo/designs

{"name":"name3","script":"body3 --> $entity1.name"}
<-- Location https://{recs-host}/api/recs/demo/designs/4
{"name":"name3","id":4,"script":"body3 --> $entity1.name"}

Validate a design

POST /recs/{client}/designs/validate
Validate a design without creating it.
REQUEST BODY
design (required) Body Parameter — Design
RETURN TYPE
RESPONSES
200
201 Created
400 Bad Request. Most probably the data provided in the request is invalid.
401 The user is not allowed to perform this operation.
403 Access to this resource is forbidden.
404 The referenced resource was not found.

Sample code

$ cat content1.js 
{"name":"name1","script":"$entity1.id --> $entity1.name"} 

$ curl -X POST  -H "Accept: application/json" -H "Content-Type: application/json; charset=UTF-8" 'http://recs/rest/recs/v1/templates/validate?client=demo&userName=eee' -d@content1.js
{"entityCount":1,"messages":[],"valid":true}  

$ cat content2.js 
{"name":"name1","script":"some body"} 

$ curl -X POST  -H "Accept: application/json" -H "Content-Type: application/json; charset=UTF-8" 'http://recs/rest/recs/v1/templates/validate?client=demo&userName=eee' -d@content2.js

{"messages":[{"keyArguments":[],"key":"error.template.validate.entitiesRequired","text":"There should be at least one entity reference within the template script"}],"valid":false}

Get a design by id

GET /recs/{client}/designs/{id}
Get a design by id.
RETURN TYPE
RESPONSES
200 OK
400 Bad Request. Most probably the data provided in the request is invalid.
401 The user is not allowed to perform this operation.
403 Access to this resource is forbidden.
404 The referenced resource was not found.
PARAMETERS
id (required) Path Parameter — integer
references (optional) Query Parameter — boolean
includeScript (optional) Query Parameter — boolean

Sample code

curl -X GET -H "Accept: application/vnd.adobe.target.v1+json" -H "X-Target-user-email: buzz@adobe.com" https://{recs-host}/api/recs/demo/design/1

{
  "name":"name", "id":2, "script":"body --> $entity1.id",
  "references": {
      "recommendations": {
        "activeCount": 1,
        "inactiveCount": 0,
        "active": [ {"id": 5, "name": "recs name" } ]
      },
      "recommendationUnits":{
        "details":[{"id":1,"name":"xxx"}],
        "count":1
      }
   }
}

Update a design by id

PUT /recs/{client}/designs/{id}
Update a design by id.
REQUEST BODY
design (required) Body Parameter — Design
RETURN TYPE
RESPONSES
200 OK
201 Created
400 Bad Request. Most probably the data provided in the request is invalid.
401 The user is not allowed to perform this operation.
403 Access to this resource is forbidden.
404 The referenced resource was not found.
PARAMETERS
id (required) Path Parameter — integer
references (optional) Query Parameter — boolean
includeScript (optional) Query Parameter — boolean

Sample code

curl -X PUT -H "Accept: application/vnd.adobe.target.v1+json" -H "Content-Type: application/vnd.adobe.target.v1+json" -H "X-Target-user-email: buzz@adobe.com" https://{recs-host}/api/recs/demo/designs/5

{"name":"name33333333","script":"body3 ---------------> $entity1.name"}

<--200 OK
{
  "name":"name33333333","id":4,"script":"body3 ---------------> $entity1.name",
  "references": {
    "recommendations": {
      "activeCount": 1,
      "inactiveCount": 0,
      "active": [ {"id": 5, "name": "recs name" } ]
    },
    "recommendationUnits":{
      "details":[{"id":1,"name":"xxx"}],
      "count":1
    }
  }
}

Delete a design

DELETE /recs/{client}/designs/{id}
Delete a design by id.
RETURN TYPE
RESPONSES
200 OK
400 Bad Request. Most probably the data provided in the request is invalid.
401 The user is not allowed to perform this operation.
204 No Content
403 Access to this resource is forbidden.
404 The referenced resource was not found.
PARAMETERS
id (required) Path Parameter — integer

Sample code

curl -X DELETE -H "Accept: application/vnd.adobe.target.v1+json" -H "Content-Type: application/vnd.adobe.target.v1+json" -H "X-Target-user-email: buzz@adobe.com" https://{recs-host}/api/recs/demo/designs/4 

{"name":"name33333333","id":4,"script":"body3 ---------------> $entity1.name"}

Field Descriptions & Validation Rules

Field Path Description Default Validation
id Read only long value, generated by server side at the time of creation. Used to identify a design in URL. System generated Must not exist on POST. Optional on PUT but must be the same as the existing id if included.
name String. Name of design. -- Must be unique, 250 characters or less and not empty.
script String. Velocity script that is used to render your recommendation. See https://marketing.adobe.com/resources/help/en_US/target/recs/c_customizing_a_template.html for more details. -- Must be valid velocity engine script with at least one entity. Cannot be blank and cannot have more that 65000 characters.