Order Structure

The basic JSON order structure is shown below

{
     "destination":  { },
     "orderData": {
          "items": [
               {
                    "components":[ ]
               }
          ],
          "shipments": [
               {
                    "shipTo": { },
                    "returnAddress": { },
                    "carrier": { }
               }
          ]
     }
}

Orders are submitted using a predefined JSON structure, any additional fields or child elements in the structure will be ignored.

The key objects in the order data structure include:

Object Description
destination Destination account for the order, for example the site where the order will be fulfilled.
orderData Contains the main order data, detailed below.
items An array of the items objects contained within the order. At least 1 item is required.
components An array of components that are contained within the order item, for example text or cover
shipments An array of shipments (destinations). These are referenced by each order item, using the shipmentIndex field. At least 1 shipment is required

Full Order Structure

Below is an example of a full order structure including fields that have default values.
It is not necessary to include all of these fields in the order.

{
     "destination": {
          "name":       "printcompanyx"
     },
     "orderData": {
          "sourceOrderId":        "41324132",
          "customerName":         "Customer Name",
          "extraData": { },
          "items": [
               {
                    "description":          "Photo Book",
                    "shipmentIndex":        0,
                    "sourceItemId":         "ORDER-13243124",
                    "sku":                  "SKU-CODE-X",
                    "dispatchAlert":        "please wrap book 1 in blue paper",
                    "quantity":             1,
                    "unitWeight":           100,
                    "barcode":              "13243124",
                    "extraData":            { },
                    "components": [
                         {
                              "sourceComponentId":  "ORDER-13243124-1",
                              "code":               "text",
                              "localFile":          false,
                              "fetch":              true,
                              "path":               "http://www.site.com/order/13243124/text.pdf",
                              "preflight":          true,
                              "duplicate":          10,
                              "barcode":            "13243124-1",
                              "attributes": {
                                   "corners": "rounded"
                              },
                              "extraData": {}
                         }
                    ]
               }
          ],
          "stockItems": [
               {
                    "code": "coupon",
                    "name": "Default Coupon",
                    "quantity": 1,
                    "shipmentIndex": 0,
                    "unitPrice": 0.25
               }
          ],
          "shipments": [
               {
                    "sourceShipmentId": "SHIPMENT-13243124-1",
                    "shipmentIndex":  0,
                    "shipByDate":     "2013-07-12",
                    "slaDays":        1,
                    "canShipEarly":   true,
                    "shipTo":{
                         "name":           "Peter Pan",
                         "companyName":    "Disney Corporation",
                         "address1":       "17 Disney Way",
                         "address2":       "",
                         "address3":       "",
                         "town":           "Los Angeles",
                         "postcode":       "34757",
                         "state":          "California",
                         "isoCountry":     "US",
                         "country":        "United States of America",
                         "email":          "peter@disney.com",
                         "phone":          "+12345678910"
                    },
                    "returnAddress": {
                         "name":           "Peter Pan",
                         "companyName":    "Disney Corporation",
                         "address1":       "17 Disney Way",
                         "address2":       "",
                         "address3":       "",
                         "town":           "Los Angeles",
                         "postcode":       "34757",
                         "state":          "California",
                         "isoCountry":     "US",
                         "country":        "United States of America",
                         "email":          "peter@disney.com"
                    },
                    "carrier": {
                         "alias":      "CUSTOM_SHIPPING"
                    },
                    "attachments": [
                         {
                              "path":     "http://some.site.com/files/insert.pdf",
                              "type":     "insert"
                         }
                    ]
               }
          ]
     }
}

A minimum order required for a single quantity sku product with a file would be as follows

{
     "destination": {
          "name": "printcompanyx"
     },
     "orderData": {
          "items": [
               {
                    "sku": "SKU-CODE-X",
                    "components": [
                         {
                              "code": "text",
                              "fetch": true,
                              "path": "http://www.site.com/text.pdf"
                         }
                    ]
               }
          ],
          "shipments": [
               {
                    "shipTo": {
                         "name": "Peter Pan",
                         "companyName": "Disney Corporation",
                         "address1": "17 Disney Way",
                         "town": "Los Angeles",
                         "postcode": "34757",
                         "isoCountry": "US"
                    },
                    "carrier":{
                         "alias": "shipping"
                    }
               }
          ]
     }
}

Field Definitions

Below are specifications for the fields defined above:

Destination

Field Required Default Options Description
name true     The account name that is order is to be sent to

OrderData

Field Required Default Options Description
sourceOrderId true     Must be set by the sender and represents their internal order id
customerName false     Customer Name
extraData false     Optional. An object that can be used to store structured data that can be included in postbacks

OrderData.Items

Field Required Default Options Description
description false     Optional. Can provide a description for the order item. Different to the configured product description
shipmentIndex false 0   An integer that corresponds to one of the items in the shipment array, it will default to the first one so should be ignored for single shipment orders
sourceItemId true     Unique within the order. Represents the internal item ID
sku true     This must be a valid SKU code which has been previously set up in the destination account
dispatchAlert false     This message will show at dispatch when the item is scanned.
quantity false 1   Item Quantity, defaults to 1
unitWeight false     unitWeight is the weight of the item. This can override what has been configured on the product.
barcode false     Customer specified barcode, can be used if the barcode is already on the artwork provided by the customer
extraData false     An object that can be used to store structured data that can be included in postbacks

OrderData.StockItems

Field Required Default Options Description
code true     Stock code for lookup
name false     Item name
quantity false 1   Item Quantity, defaults to 1
shipmentIndex false 0   An integer that corresponds to one of the items in the shipment array, it will default to the first one so should be ignored for single shipment orders
unitPrice false 0   unitPrice (RRP) is the price the item has been sold to the end consumer for. It is sent to the carrier and is used for customs purposes.

OrderData.Items.Component

Field Required Default Options Description
code true     Used to map this object to the corresponding component in the OneFlow product
path true     The artwork for the component. You must set either ‘fetch’ to true or ‘localFile’ to true
fetch True if localFile is false false   If true, the file will be fetched from a URL (in the above ‘path’ field) into OneFlow’s cloud storage
localFile True if fetch is false false   If true, the file won’t be fetched and must already exist on site at the print company
preflight false false   Tells OneFlow whether to preflight the submitted artwork. This is false if localFile = true
sourceComponentId false     Provides a field for customer specified component ID
duplicate false 1   Number of duplications to make of the component. 1 means no duplication.
barcode false     The barcode for the component
attributes false     A dictionary of key-value pairs that specify attributes that define this component that have been configured in the destination account
extraData false     Optional. An object that can be used to store structured data that can be included in postbacks

OrderData.Shipments

Field Required Default Options Description
sourceShipmentId false     Optional field to specify a reference number for the sender’s shipment
shipmentIndex false     The index of this shipment (referenced by items.shipmentIndex)
shipByDate false     Date that it needs to be shipped, in the format “yyyy-mm-dd”
slaDays false     slaDays can be used to override what has been configured on the SKU. PSPs can set a min SLA that will ensure that the item is given an agreed minimum amount of time to be produced.
canShipEarly false true   Whether the shipment can be shipped earlier than shipByDate or not
shipTo.name true     Shipping Name
shipTo.companyName false     Optional. Company Name
shipTo.address1 true     Line 1 of Address
shipTo.address2 false     Line 2 of Address
shipTo.address3 false     Line 3 of Address
shipTo.town true     City / Town
shipTo.postcode true     Postcode or Zip code
shipTo.state false     Optional. State of address
shipTo.isoCountry true     2 Character ISO Country code
shipTo.phone false     Phone number for Address. Required for some carriers i.e. Fedex
returnAddress.name true     Shipping Name
returnAddress.companyName false     Optional. Company Name
returnAddress.address1 true     Line 1 of Address
returnAddress.address2 false     Line 2 of Address
returnAddress.address3 false     Line 3 of Address
returnAddress.town true     City / Town
returnAddress.postcode false     Postcode or Zip code
returnAddress.state false     Optional. State of address
returnAddress.isoCountry true     2 Character ISO Country code
carrier.alias true     The alias for the shipping service being used to ship the order
attachments false     Allows the attachment of additional files (fetch only) such as packing slips