We're software that helps growing brands & retailers grow and scale. Sync, sell and ship your products and inventory on online marketplaces and storefronts faster, easier and more accurately.

Learn more now

Order Export Automations

What Is an Order Export?

An order export automation sends order data from SureDone to an external system. Common scenarios include:

  • Dropship fulfillment -- Send purchase orders to your supplier so they can ship directly to your customer.
  • Warehouse management -- Push order details to a 3PL or WMS for picking and packing.
  • Invoicing and accounting -- Email daily order reports to your finance team.
  • Tracking updates -- Notify a partner system when orders ship.
  • Custom integrations -- Push order data to an ERP, CRM, or any system with an API or file-based intake.

The engine gathers orders matching your search criteria, formats them according to your configuration, and delivers them via FTP, SFTP, HTTP API, or email.

Searching for Orders

The search config selects which orders to include in the export. It uses SureDone's standard search syntax:


"search": "status:=READY archived:=0"

This exports orders with a status of "READY" that are not archived. You can combine any searchable order fields:


"search": "status:-=COMPLETE status:-=CANCELED status:-=ARCHIVED archived:=0 date:>=\"-1 day\""

This exports all non-completed, non-canceled, non-archived orders from the last 24 hours.

Important: Without a search config, the export includes all orders. Always set a search to avoid re-exporting orders that have already been sent.

Templates for Order Exports

Most order exports use Twig templates to format the output as JSON, XML, or a custom structure. The data variable in the template contains all mapped order fields.

For a simple JSON payload sending one order at a time (payload_multi: false):


"template": "{\"po_number\": \"{{data['oid']}}\", \"ship_to\": {\"name\": \"{{data['shippingfirstname']}} {{data['shippinglastname']}}\", \"address\": \"{{data['shippingstreet1']}}\", \"city\": \"{{data['shippingcity']}}\", \"state\": \"{{data['shippingstateprovince']}}\", \"zip\": \"{{data['shippingpostalcode']}}\"}}"

Templates give you complete control over the structure. You can include conditional logic, loops over line items, string formatting, and Twig filters.

Payload Multi for Orders

The payload_multi config controls whether orders are exported individually or in bulk:

payload_multi: false (default for exports) -- The engine creates one export per order. For HTTP connections, this means one API call per order. For file connections, this means one file per order (unless using a template that aggregates). This is the most common setup for API-based order submission.

payload_multi: true -- All matching orders are bundled into a single file or request. The template receives the full data array and must iterate over it:


"template": "[{% for key, value in data %}{% if key > 0 %},{% endif %}{\"order\": \"{{value['oid']}}\", \"total\": {{value['total']}}}{% endfor %}]"

This is common for file-based exports (CSV to FTP) and batch API endpoints.

Tip: When using payload_multi: true with a large number of orders, use limit_export to cap the number of orders per request and automatically split into batches.

Line Item Handling

Orders often contain multiple line items, and your export may need to handle them differently depending on the vendor's requirements.

order_payload_line_item -- Set to true to split multi-item orders into separate lines. An order with 3 items becomes 3 rows in your export, each with the order-level data (address, status) repeated alongside the item-level data (SKU, quantity, price). This is the standard format for CSV exports to vendors:


"order_payload_line_item": true

order_payload_line_delimiter -- When using line items with templates, this specifies the delimiter between items. Defaults to *.

order_payload_line_filter -- Set to true to filter out line items that do not match the search criteria, even if they belong to an order that does match. This is essential for dropship scenarios where an order may contain items from multiple suppliers:


"search": "supplier:=AcmeParts status:-=COMPLETE archived:=0",
"order_payload_line_item": true,
"order_payload_line_filter": true

With this configuration, only line items where supplier is "AcmeParts" are exported. Items from other suppliers in the same order are excluded.

Updating Orders on Export

The order_update_export config automatically updates order fields after a successful export. This is how you mark orders as "sent" so they are not exported again:


"order_update_export": {
    "status": "ORDERED",
    "itemstatus": "ORDERED"
}

After each order is successfully exported, its status and itemstatus are set to "ORDERED". On the next run, your search (which excludes "ORDERED" orders) skips them automatically.

Warning: Make sure your search criteria exclude orders with the status you set in order_update_export. Otherwise, the same orders will be exported repeatedly. A common pattern is status:-=ORDERED status:-=COMPLETE in the search with "status": "ORDERED" in the update.

The order_update_search config adds an extra filter for which orders get updated after export. This is useful when order_payload_line_item is enabled and you only want to update specific items:


"order_update_export": {
    "itemstatus": "ORDERED"
},
"order_update_search": "supplier:=AcmeParts"

This only updates the itemstatus for line items where supplier is "AcmeParts", leaving other items in the same order untouched.

Response Mapping

When exporting to an HTTP API, the vendor may return useful data in their response -- a confirmation number, an estimated ship date, a vendor order ID. Use response_field_map to save this data back to SureDone:


"response_field_map": {
    "vendororderid": "$.confirmation_number",
    "vendorstatus": "$.order_status",
    "shiptracking": "$.tracking_number"
}

This maps the vendor's response fields to SureDone order fields. The data is saved automatically after each successful export.

Note: When using JSONPath syntax (e.g. $.confirmation_number) in response_field_map values, you must also set "jsonpath": true in the same file_config. Without it, the engine cannot parse the JSONPath expressions and will throw an error.

Date Range

Use orders_start_date and orders_end_date to limit the export to orders within a specific time window:


"orders_start_date": "-7 days",
"orders_end_date": "now"

These accept any valid PHP datetime format string. They are particularly useful for report-style exports where you want to capture a specific period.

Complete Example: Order Export to Vendor API via HTTP with Template

This automation sends new orders to a dropship supplier's REST API, one order at a time, and saves the vendor's confirmation number back to SureDone.


{
    "name": "Dropship Order Submission",
    "vendor": "AcmeSupply",
    "active": true,
    "schedule": "*/30 * * * *",
    "type": "orders",
    "action": "export",
    "connection": {
        "type": "http",
        "address": "https://api.acmesupply.com/v2/orders",
        "method": "POST",
        "headers": {
            "Content-Type": "application/json",
            "Authorization": "Bearer {{api_key}}"
        }
    },
    "file_configs": [
        {
            "search": "supplier:=AcmeSupply status:=READY archived:=0",
            "template": "{\"po_number\": \"{{data['oid']}}\", \"ship_to\": {\"name\": \"{{data['shippingfirstname']}} {{data['shippinglastname']}}\", \"address1\": \"{{data['shippingstreet1']}}\", \"address2\": \"{{data['shippingstreet2']}}\", \"city\": \"{{data['shippingcity']}}\", \"state\": \"{{data['shippingstateprovince']}}\", \"zip\": \"{{data['shippingpostalcode']}}\", \"country\": \"{{data['shippingcountry']}}\", \"phone\": \"{{data['shippingphone']}}\"}, \"items\": [{\"sku\": \"{{data['sku']}}\", \"qty\": {{data['quantity']}}, \"price\": {{data['price']}}}]}",
            "order_payload_line_item": true,
            "order_payload_line_filter": true,
            "field_map": {
                "sku": "sku",
                "quantity": "quantity",
                "price": "price"
            },
            "field_run": {
                "oid": "oid",
                "shippingfirstname": "shippingfirstname",
                "shippinglastname": "shippinglastname",
                "shippingstreet1": "shippingstreet1",
                "shippingstreet2": "shippingstreet2",
                "shippingcity": "shippingcity",
                "shippingstateprovince": "shippingstateprovince",
                "shippingpostalcode": "shippingpostalcode",
                "shippingcountry": "shippingcountry",
                "shippingphone": "shippingphone"
            },
            "response_field_map": {
                "vendororderid": "$.confirmation_id",
                "vendorstatus": "$.status"
            },
            "order_update_export": {
                "status": "ORDERED",
                "itemstatus": "ORDERED"
            },
            "order_update_search": "supplier:=AcmeSupply",
            "jsonpath": true
        }
    ],
    "parameters": [
        {
            "name": "api_key",
            "value": "",
            "encrypted": true,
            "label": "AcmeSupply API Key"
        }
    ]
}

What this does:

  • Runs every 30 minutes
  • Finds orders where supplier is "AcmeSupply", status is "READY", and not archived
  • Sends each order to the vendor's API as a JSON POST with shipping details and line items
  • Filters line items so only AcmeSupply items are included (other suppliers' items in the same order are excluded)
  • Saves the vendor's confirmation_id and status from the API response back to SureDone
  • Marks the order and its items as "ORDERED" so they are not exported again
  • Only updates itemstatus for AcmeSupply items, leaving other suppliers' items unchanged

Complete Example: Order CSV Export to SFTP with Line Items

This automation exports a daily CSV of completed orders to your accounting team's SFTP server, with one row per line item.


{
    "name": "Daily Orders Report",
    "vendor": "Internal",
    "active": true,
    "schedule": "0 6 * * *",
    "type": "orders",
    "action": "export",
    "connection": {
        "type": "sftp",
        "address": "sftp.suredone.com",
        "username": "{{sftp_user}}",
        "password": "{{sftp_pass}}",
        "path": "/reports/orders",
        "port": 22
    },
    "file_configs": [
        {
            "name": "orders-{{DATE}}.csv",
            "date_format": "Y-m-d",
            "search": "status:=COMPLETE date:>=\"-1 day\"",
            "order_payload_line_item": true,
            "field_map": {
                "dateutc": "Order Date",
                "oid": "Order ID",
                "order": "Order Number",
                "sku": "SKU",
                "title": "Product Title",
                "quantity": "Qty",
                "price": "Unit Price",
                "total": "Order Total",
                "shippingtotal": "Shipping",
                "taxtotal": "Tax",
                "email": "Buyer Email",
                "shippingstateprovince": "Ship State",
                "shippingcountry": "Ship Country"
            },
            "field_run": {
                "channel": "channel"
            },
            "headers": true
        }
    ],
    "parameters": [
        {
            "name": "sftp_user",
            "value": "",
            "label": "SFTP Username"
        },
        {
            "name": "sftp_pass",
            "value": "",
            "encrypted": true,
            "label": "SFTP Password"
        }
    ]
}

What this does:

  • Runs daily at 6:00 AM UTC
  • Exports all orders completed in the last 24 hours
  • Creates one row per line item (an order with 3 items becomes 3 rows)
  • Includes order date, IDs, product details, pricing, shipping, tax, and buyer info
  • Uploads as orders-2026-03-30.csv with column headers