Skip to content

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/print

Authentication

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.

FieldTypeRequiredDescription
idstringYesProject ID (starts with p-)
productobjectNoProduct details (if changed from original)
product.pspstringNoPrinter name
product.skustringNoProduct SKU
product.marketIdstring/integerNoMarket ID
lineItemTotalnumberYesTotal cost for this line item
quantityintegerYesNumber of copies to print
metadataobjectNoAdditional data (coordinate with PBAI team)
metadata.colorCorrectionbooleanNoEnable 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.

FieldTypeRequiredDescription
grandTotalnumberYesTotal amount paid by user
couponobjectNoCoupon/discount information
coupon.valuenumberNoDiscount amount
coupon.codestringNoCoupon code used
methodstringNoPayment method (e.g., "stripe", "paypal")
referencestringNoPayment reference/transaction ID
shippingobjectNoShipping details
shipping.methodstringNoShipping method name
shipping.costnumberNoShipping cost

user (object, required)

User and delivery information.

FieldTypeRequiredDescription
firstNamestringNoUser's first name
lastNamestringNoUser's last name
telephonestringNoContact phone number
addressobjectYesDelivery address
address.line1stringYesAddress line 1
address.line2stringNoAddress line 2 (apartment, suite, etc.)
address.postcodestringYesPostal/ZIP code
address.citystringNoCity
address.statestringNoState/province
address.countryIso2stringYesISO 3166-1 alpha-2 country code (e.g., "US", "GB")
address.companystringNoCompany name

orderId (string, required)

Your internal order ID for reference.

Response

json
{
  "message": "Projects [p-abc123xyz] requested for processing"
}
FieldTypeDescription
messagestringConfirmation 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

  1. User Completes Payment - Your checkout system processes payment
  2. Call Print API - Trigger rendering and printing with this endpoint
  3. Backend Processing - PWA backend:
    • Renders the photobook at print resolution
    • Applies any requested processing (e.g., color correction)
    • Generates print-ready files
  4. Submit to PSP - Job is sent to the printer

Suggested Practices

  1. Call After Payment - Only call this API after payment is successfully processed
  2. Include Applicable Projects - Include all applicable line items in the order in the projects array
  3. Accurate Totals - Ensure lineItemTotal and grandTotal match your checkout calculations
  4. 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.

photobook.ai Developer Documentation