Integration and API Spec
The reference during the build: every tool connection, auth scope, field mapping, and error-handling rule.
Integration and API Spec
Order Processing & Fulfilment
[YourCompany.com] · Fulfilment Department · Prepared by FullSpec · [Today's Date]
This document is the authoritative technical reference for every integration point in the Order Processing and Fulfilment automation. It covers authentication methods, required OAuth scopes, webhook configurations, field mappings between tools, credential-store structure, orchestration layout, and error-handling behaviour for all six connected platforms. The FullSpec team uses this spec during build, QA, and any post-launch debugging. Your team should treat it as the source of truth whenever a connection is reconfigured or a credential is rotated.
01Tool inventory
02Per-tool integration detail
Acts as both the automation trigger (paid order webhook) and the write-back destination (fulfillment status and tracking number). Used by Agent 1 (Order Routing) and Agent 2 (Label and Despatch).
// Inbound webhook payload (orders/paid) - key fields
order.id -> string // Shopify order ID, used as idempotency key
order.line_items[] -> array // SKU, quantity, variant_id per line
order.shipping_address -> object // name, address1, city, province_code, zip, country_code
order.total_price -> string // order total in store currency
// Write-back (PUT /admin/api/2024-01/orders/{id}/fulfillments.json)
fulfillment.tracking_number -> string
fulfillment.tracking_company -> string
fulfillment.tracking_url -> string
fulfillment.location_id -> string // from SHOPIFY_LOCATION_IDProvides real-time inventory data for the stock check in Agent 1 and receives pick-list creation instructions after an order is confirmed in stock.
// Stock check request (POST /api/Stock/GetStockItemsFull) request.body.searchType -> 'SKU' request.body.searchValue -> line_item.sku // from Shopify order // Stock check response - key fields response[0].StockItemId -> string // internal Linnworks ID response[0].Locations[0].Available -> number // available quantity // Pick list creation (POST /api/Orders/CreateOrders) order.ReferenceNum -> shopify_order_id order.ItemSKU -> line_item.sku order.Quantity -> line_item.quantity
Receives exception alerts from Agent 1 when one or more SKUs on an order are out of stock. The fulfilment manager reviews the alert and acts manually.
// Outbound message payload (chat.postMessage) channel -> SLACK_EXCEPTION_CHANNEL_ID text -> 'Out-of-stock exception: Order #' + order.id blocks[].fields[].text -> sku, quantity_ordered, quantity_available blocks[].actions[].url -> 'https://' + SHOPIFY_SHOP_DOMAIN + '/admin/orders/' + order.id
Receives confirmed order data from Agent 2, applies carrier selection rules, generates the shipping label, and returns the tracking number and label PDF URL.
// Create order + label request (POST /shipments/createlabel) request.orderId -> shopify_order_id // used as externalOrderId request.carrierCode -> from SHIPSTATION_CARRIER_RULES lookup request.serviceCode -> from SHIPSTATION_CARRIER_RULES lookup request.weight.value -> order.total_weight_grams request.shipTo.name -> order.shipping_address.name request.shipTo.street1 -> order.shipping_address.address1 request.shipTo.city -> order.shipping_address.city request.shipTo.state -> order.shipping_address.province_code request.shipTo.postalCode -> order.shipping_address.zip request.shipTo.country -> order.shipping_address.country_code // Label creation response - key fields response.trackingNumber -> string // passed to Shopify and Xero response.labelUrl -> string // PDF label for warehouse printing response.shipmentCost -> number // USD, passed to Xero response.carrierCode -> string // confirmed carrier
Receives the shipment cost from Agent 2 and posts it as a line item against the corresponding sales invoice or order in Xero.
// POST /api.xro/2.0/Invoices (add line item to existing invoice) Invoice.InvoiceNumber -> shopify_order_id // used to locate the invoice LineItem.Description -> 'Shipping: ' + response.carrierCode + ' ' + response.trackingNumber LineItem.Quantity -> 1 LineItem.UnitAmount -> shipstation_response.shipmentCost // number, 2dp LineItem.AccountCode -> XERO_SHIPPING_ACCOUNT_CODE LineItem.TaxType -> XERO_TAX_TYPE
Receives a trigger event from the orchestration layer when Shopify fires the fulfillments/create webhook. Sends the branded tracking email to the customer using a pre-built Klaviyo flow.
// POST /api/events/ (Klaviyo Events API v2024-02-15) data.type -> 'event' data.attributes.metric.name -> KLAVIYO_METRIC_NAME // 'Order Shipped' data.attributes.profile.email -> order.email data.attributes.properties.tracking_number -> shipstation_response.trackingNumber data.attributes.properties.tracking_url -> shopify_fulfillment.tracking_url data.attributes.properties.carrier_name -> shipstation_response.carrierCode data.attributes.properties.estimated_delivery -> shipstation_response.estimatedDeliveryDate data.attributes.properties.order_id -> shopify_order_id
03Field mappings between tools
The following tables define the exact field mappings at each agent handoff point. Field names are shown in monospace as they appear in the respective API payloads or credential store. All mappings are implemented in the orchestration layer; no manual data entry occurs at any handoff.
Agent 1 handoff: Shopify paid order to Linnworks stock check
Agent 1 handoff: Linnworks stock check result to Slack exception alert (out-of-stock path only)
Agent 2 handoff: Shopify order plus Linnworks confirmation to ShipStation label creation
Agent 2 handoff: ShipStation label response to Shopify fulfilment write-back
Agent 2 handoff: ShipStation label response to Xero cost posting
Agent 3 handoff: Shopify fulfilment event to Klaviyo tracking email trigger
04Build stack and orchestration
// CREDENTIAL STORE CONTENTS
// All values stored as encrypted environment variables in the automation platform
// Shopify
SHOPIFY_API_TOKEN = 'shpat_xxxxxxxxxxxxxxxxxxxxxxxxxxxx'
SHOPIFY_WEBHOOK_SECRET = 'whsec_xxxxxxxxxxxxxxxxxxxxxxxxxxxx'
SHOPIFY_SHOP_DOMAIN = 'yourcompany.myshopify.com'
SHOPIFY_API_VERSION = '2024-01'
SHOPIFY_LOCATION_ID = '12345678901234'
// Linnworks
LINNWORKS_APP_ID = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
LINNWORKS_APP_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
LINNWORKS_APP_TOKEN = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
LINNWORKS_API_BASE = 'https://api.linnworks.net'
LINNWORKS_LOCATION_GUID = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
// Slack
SLACK_BOT_TOKEN = 'xoxb-xxxxxxxxxxxx-xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxx'
SLACK_EXCEPTION_CHANNEL_ID = 'C0XXXXXXXXXXX'
SLACK_WEBHOOK_URL = 'https://hooks.slack.com/services/T.../B.../xxxx'
// ShipStation
SHIPSTATION_API_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
SHIPSTATION_API_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
SHIPSTATION_STORE_ID = '123456'
SHIPSTATION_WAREHOUSE_ID = '654321'
SHIPSTATION_CARRIER_RULES = '{"0-500g-UK":"royalmail/rm24","501-2000g-UK":"royalmail/rm48","0-2000g-US":"ups/ups_ground"}'
// Xero
XERO_CLIENT_ID = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
XERO_CLIENT_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
XERO_ACCESS_TOKEN = '<rotated by platform, stored on refresh>'
XERO_REFRESH_TOKEN = '<rotated by platform, stored on refresh>'
XERO_TENANT_ID = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
XERO_SHIPPING_ACCOUNT_CODE = '420'
XERO_TAX_TYPE = 'NONE'
// Klaviyo
KLAVIYO_PRIVATE_API_KEY = 'pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
KLAVIYO_METRIC_NAME = 'Order Shipped'
KLAVIYO_FLOW_ID = 'XXXXXXXXXXX'
KLAVIYO_TEMPLATE_ID = 'XXXXXXXXXXX'05Error handling and retry logic
More documents for this process
Every document generated for Order Processing & Fulfilment.