Attraqt
Search…
Step by Step guide

Example

Here we'll show an example of a parent item and a variant being sent. Once the items have been sent, we will promote the catalog as active. We then send a patch on the variant.
The sample of items:
Item parent
1
{
2
"id": "A0001",
3
"attributes": {
4
"title": "My item",
5
"description": "This is my item."
6
}
7
}
Copied!
Item variant
1
{
2
"id": "B0001",
3
"attributes": {
4
"price": 2000,
5
"color": "red"
6
},
7
"parentId": "A0001"
8
}
Copied!

Create the item schema

The first step is to create an item schema. It must contain the attributes of the item and its variant.
Request
Response
POST /item-schemas?tenant=mycompany&environment=production
1
{
2
"name": "product",
3
"attributes": [
4
{
5
"name": "title",
6
"type": "TEXT"
7
},
8
{
9
"name": "description",
10
"type": "TEXT"
11
}
12
],
13
"nestedItemSchemas": [
14
{
15
"name": "variant",
16
"attributes": [
17
{
18
"name": "price",
19
"type": "INTEGER"
20
},
21
{
22
"name": "color",
23
"type": "TEXT"
24
}
25
]
26
}
27
]
28
}
Copied!
1
{
2
"version": 1
3
}
Copied!

Create the catalog

Next, create a catalog version. As this is the first catalog the version is 1, but you can list your catalogs.
Request
Response
POST /catalogs?tenant=mycompany&environment=production
1
{
2
"catalogItemSchemas": [
3
{
4
"name": "product",
5
"version": 1
6
}
7
]
8
}
Copied!
1
{
2
"version": 1
3
}
Copied!

Sending the items

Request
Response
POST /items?tenant=mycompany&environment=production
1
[
2
{
3
"id": "A0001",
4
"catalogVersion": 1,
5
"type": "product",
6
"attributes": {
7
"title": "My item",
8
"description": "This is my item."
9
}
10
},
11
{
12
"id": "B0001",
13
"catalogVersion": 1,
14
"type": "variant",
15
"attributes": {
16
"price": 2000,
17
"color": "red"
18
},
19
"parentId": "A0001"
20
}
21
]
Copied!
1
{
2
"requestIds": [
3
{
4
"itemId": {
5
"id": "A0001",
6
"catalogVersion": 1,
7
"context": "",
8
"type": "product",
9
"tenant": "mycompany",
10
"environment": "production"
11
},
12
"requestId": "1888742087434729"
13
},
14
{
15
"itemId": {
16
"id": "B0001",
17
"catalogVersion": 1,
18
"context": "",
19
"type": "variant",
20
"tenant": "mycompany",
21
"environment": "production"
22
},
23
"requestId": "1888742087434730"
24
}
25
]
26
}
Copied!
Then, promote your catalog version.
1
POST /catalogs/promote/1?tenant=mycompany&environment=production
Copied!
After a short period of time, the catalog will be active and usable.

Patch method

To quickly change the attribute of an item, use the patch method.
Here is an example of changing the price of the variant:
Request
PATCH /items?tenant=mycompany&environment=production
1
[
2
{
3
"id": "B0001",
4
"catalogVersion": 1,
5
"type": "variant",
6
"attributes": {
7
"price": 1500,
8
},
9
"parentId": "A0001"
10
}
11
]
Copied!
Last modified 21d ago