Save
You can save a product state to Asset Storage by using the POST ~/api/product/save endpoint. This endpoint accepts a product object, userId, and stateId, and returns an array of origin file URLs and the stateId.
Request Payload
To save a product, pass the product data, userId, and stateId in the request body:
{
"product": {
"surfaces": [
{
"printAreas": [
{
"design": {
"file": "425a3537-2e59-450d-bbc2-484fcd3d63bd.pdf"
}
}
]
}
]
},
"userId": "user@example.com",
"stateId": "4afcbe97-b51d-4f6f-b9db-70c55536b80a"
}
Example call
const saveProduct = async () => {
const response = await fetch(appUrl + "api/product/save", {
method: "POST",
body: JSON.stringify({
product: {
surfaces: [
{
printAreas: [
{
design: {
file: "425a3537-2e59-450d-bbc2-484fcd3d63bd.pdf"
}
}
]
}
]
},
userId: "user@example.com",
stateId: "4afcbe97-b51d-4f6f-b9db-70c55536b80a"
}),
headers: {
'Content-Type': 'application/json'
}
});
const result = await response.json();
console.log(result);
};
Success response
This endpoint returns an array of origin file URLs and the stateId:
Status Code: 200 OK
Content:
{
"originUrls": [
"http://example.com/pt/api/files/get/425a3537-2e59-450d-bbc2-484fcd3d63bd.pdf"
],
"stateId": "4afcbe97-b51d-4f6f-b9db-70c55536b80a"
}