Appearance
Print / Complete Job
API Type
PWA Backend API - Uses access keys in X-Albumstory header. See Authentication.
Trigger final processing, rendering, and submission of photobook projects to the printer after payment is completed.
Environment URLs:
- Development:
https://pwa-api-dev.photobook.ai/v2/* - Production:
https://pwa-api.photobook.ai/v2/*
Complete the Job
After the user completes payment, call this API to render the photobook and send the job to the PSP for printing.
Endpoint
POST https://pwa-api{-env}.photobook.ai/v2/printAuthentication
See Authentication - PWA Backend
Request Parameters
json
{
"projects": [
{
"id": "p-abc123xyz",
"product": {
"psp": "PrinterName",
"sku": "PB001",
"marketId": "custom-market"
},
"lineItemTotal": 65.98,
"quantity": 2,
"metadata": {
"colorCorrection": true
}
}
],
"payment": {
"grandTotal": 71.97,
"coupon": {
"value": 5.00,
"code": "SAVE5"
},
"method": "stripe",
"reference": "ch_abc123",
"shipping": {
"method": "standard",
"cost": 5.99
}
},
"user": {
"firstName": "John",
"lastName": "Doe",
"telephone": "+1234567890",
"address": {
"line1": "123 Main Street",
"line2": "Apt 4B",
"postcode": "10001",
"city": "New York",
"state": "NY",
"countryIso2": "US",
"company": "Acme Corp"
}
},
"orderId": "ORD-2024-12345"
}Request Fields
projects (array, required)
List of projects in the order.
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Project ID (starts with p-) |
product | object | No | Product details (if changed from original) |
product.psp | string | No | Printer name |
product.sku | string | No | Product SKU |
product.marketId | string/integer | No | Market ID |
lineItemTotal | number | Yes | Total cost for this line item |
quantity | integer | Yes | Number of copies to print |
metadata | object | No | Additional data (coordinate with PBAI team) |
metadata.colorCorrection | boolean | No | Enable color correction during rendering |
Product Field
The product field is optional. You can include it if any product details (psp, sku, marketId) have changed since project creation, or populate it even if unchanged.
payment (object, required)
Payment and order details.
| Field | Type | Required | Description |
|---|---|---|---|
grandTotal | number | Yes | Total amount paid by user |
coupon | object | No | Coupon/discount information |
coupon.value | number | No | Discount amount |
coupon.code | string | No | Coupon code used |
method | string | No | Payment method (e.g., "stripe", "paypal") |
reference | string | No | Payment reference/transaction ID |
shipping | object | No | Shipping details |
shipping.method | string | No | Shipping method name |
shipping.cost | number | No | Shipping cost |
user (object, required)
User and delivery information.
| Field | Type | Required | Description |
|---|---|---|---|
firstName | string | No | User's first name |
lastName | string | No | User's last name |
telephone | string | No | Contact phone number |
address | object | Yes | Delivery address |
address.line1 | string | Yes | Address line 1 |
address.line2 | string | No | Address line 2 (apartment, suite, etc.) |
address.postcode | string | Yes | Postal/ZIP code |
address.city | string | No | City |
address.state | string | No | State/province |
address.countryIso2 | string | Yes | ISO 3166-1 alpha-2 country code (e.g., "US", "GB") |
address.company | string | No | Company name |
orderId (string, required)
Your internal order ID for reference.
Response
json
{
"message": "Projects [p-abc123xyz] requested for processing"
}| Field | Type | Description |
|---|---|---|
message | string | Confirmation message listing processed projects |
Example Implementation
javascript
async function completeOrder(orderData) {
const requestData = {
projects: orderData.projects.map(project => ({
id: project.id,
lineItemTotal: project.total,
quantity: project.quantity,
metadata: {
colorCorrection: project.colorCorrection || false
}
})),
payment: {
grandTotal: orderData.grandTotal,
method: orderData.paymentMethod,
reference: orderData.paymentReference,
shipping: {
method: orderData.shippingMethod,
cost: orderData.shippingCost
}
},
user: {
firstName: orderData.customer.firstName,
lastName: orderData.customer.lastName,
telephone: orderData.customer.phone,
address: {
line1: orderData.shippingAddress.street,
line2: orderData.shippingAddress.unit,
postcode: orderData.shippingAddress.zip,
city: orderData.shippingAddress.city,
state: orderData.shippingAddress.state,
countryIso2: orderData.shippingAddress.country
}
},
orderId: orderData.orderId
};
const response = await fetch('https://pwa-api-dev.photobook.ai/v2/print', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Albumstory': JSON.stringify({
accessKey: process.env.PWA_ACCESS_KEY,
accessSecret: process.env.PWA_ACCESS_SECRET
})
},
body: JSON.stringify(requestData)
});
const data = await response.json();
console.log(data.message);
}Processing Flow
- User Completes Payment - Your checkout system processes payment
- Call Print API - Trigger rendering and printing with this endpoint
- Backend Processing - PWA backend:
- Renders the photobook at print resolution
- Applies any requested processing (e.g., color correction)
- Generates print-ready files
- Submit to PSP - Job is sent to the printer
Suggested Practices
- Call After Payment - Only call this API after payment is successfully processed
- Include Applicable Projects - Include all applicable line items in the order in the
projectsarray - Accurate Totals - Ensure
lineItemTotalandgrandTotalmatch your checkout calculations - Complete Address - Provide complete shipping address to avoid delivery issues
Metadata Fields
The metadata object in each project can contain additional fields. Coordinate with the PBAI team to define custom metadata fields for your integration.
Example Metadata Fields:
colorCorrection(boolean) - Enable automatic color correction (requires coordination with PBAI team)
Custom Fields - Discuss with PBAI team for:
- Special finishing options
- Custom printing instructions
- Internal tracking codes
- PSP-specific parameters
Common Issues
Missing Address Fields
Ensure all required address fields are provided, especially line1, postcode, and countryIso2.
Invalid Project ID
Project IDs must start with p- and be valid projects created via the generate API.