high level steps for getting a mockup via their rest API
Get all products: https://api.printful.com/products e.g we’re interested in stickers:
{
"id": 505,
"main_category_id": 202,
"type": "STICKER",
"description": "These glossy stickers are designed just for you. Give your favorite items, like a notepad, laptop, or phone case an extra glow and personal touch. \n\n• Film type: MPI 3000 Gloss HOP (EU), Promotional Monomeric PVC (US)\n• 0.12″ (0.3 cm) white sticker border \n• Glossy finish\n• Fast and easy application\n• 2–3 year durability\n• Indoor use\n• Blank product sourced from Japan\n\nDon't forget to clean the surface before applying the stickers.",
"type_name": "Kiss Cut Sticker Sheet",
}
Use id505
to make the next request:
https://api.printful.com/products/505
This returns full Printful stock, variants and other useful details about this product. Most importantly keep notes of the variant IDs, eg "id": 12917
.
Use the product id again to get printfiles for this product: https://api.printful.com/mockup-generator/printfiles/505
e.g response:
{
"code": 200,
"result": {
"product_id": 505,
"available_placements": {
"default": "Print file",
"background": "Background"
},
"printfiles": [
{
"printfile_id": 256,
"width": 1750,
"height": 2482,
"dpi": 300,
"fill_mode": "fit",
"can_rotate": false
},
{
"printfile_id": 259,
"width": 1822,
"height": 2554,
"dpi": 300,
"fill_mode": "cover",
"can_rotate": false
}
],
"variant_printfiles": [
{
"variant_id": 12917,
"placements": {
"default": 256,
"background": 259
}
}
],
"option_groups": [
"Flat",
"Holiday season",
"Lifestyle",
"Lifestyle 2",
"Lifestyle 3",
"Lifestyle 4",
"Spring/summer vibes",
"Valentine's Day",
"template"
],
"options": [
"Background",
"Christmas",
"Christmas 2",
"Front",
"Spring/Summer",
"Spring/Summer 2",
"Valentine's Day",
"Valentine's Day 2"
]
},
"extra": []
}
we’re now ready to form a mockup generator request: https://api.printful.com/mockup-generator/create-task/505
This is a POST
request which need a body with a payload like:
{
"variant_ids": [
12917,
],
"format": "jpg",
"files": [
{
"placement": "default",
"image_url": "https://clever-stork-292.convex.cloud/api/storage/9fdcfdeb-ee06-47a2-83ff-01184c939d0d",
"position": {
"area_width": 1800,
"area_height": 1800,
"width": 1800,
"height": 1800,
"top": 0,
"left": 0
}
},
]
}
this will return a task that can be polled at an interval:
{
"code": 200,
"result": {
"task_key": "gt-645099290",
"status": "pending"
},
"extra": []
}
https://api.printful.com/mockup-generator/task?task_key= + {task_key}
TODO:
figure out out to automate placing an order:
https://api.printful.com/orders POST w/ works:
{
"external_id": "sticker-2-4235234213",
"shipping": "STANDARD",
"recipient": {
"name": "John Smith",
"company": "John Smith Inc",
"address1": "19749 Dearborn St",
"address2": "string",
"city": "Chatsworth",
"state_code": "CA",
"state_name": "California",
"country_code": "US",
"country_name": "United States",
"zip": "91311",
"phone": "string",
"email": "[email protected]",
"tax_number": "123.456.789-10"
},
"items": [
{
"id": 1,
"external_id": "sticker-item-2",
"variant_id": 1,
"quantity": 1,
"price": "13.00",
"retail_price": "13.00",
"name": "Kiss Cut Sticker Sheet",
"product": {
"variant_id": 12917,
"product_id": 505,
"image": "https://printful-upload.s3-accelerate.amazonaws.com/tmp/71dbbab32afaf7a761f7a28b91ac9268/kiss-cut-sticker-sheet-white-front-6600501f5d2c0.png",
"name": "Kiss Cut Sticker Sheet"
},
"files": [
{
"type": "default",
"url": "https://printful-upload.s3-accelerate.amazonaws.com/tmp/71dbbab32afaf7a761f7a28b91ac9268/kiss-cut-sticker-sheet-white-front-6600501f5d2c0.png",
"options": [
{
"id": "template_type",
"value": "native"
}
],
"filename": "shirt1.png",
"visible": true,
"position": {
"area_width": 18,
"area_height": 2400,
"width": 1800,
"height": 1800,
"top": 300,
"left": 0,
"limit_to_print_area": true
}
}
],
"options": [
{
"id": "OptionKey",
"value": "OptionValue"
}
],
"sku": null,
"discontinued": true,
"out_of_stock": true
}
],
"retail_costs": {
"currency": "USD",
"subtotal": "10.00",
"discount": "0.00",
"shipping": "5.00",
"tax": "0.00"
},
"gift": {
"subject": "To John",
"message": "Have a nice day"
},
"packing_slip": {
"email": "[email protected]",
"phone": "+371 28888888",
"message": "Message on packing slip",
"logo_url": "http://www.your-domain.com/packing-logo.png",
"store_name": "Your store name",
"custom_order_id": "kkk2344lm"
}
}