Why use the sales order import
When you move to The Layer, the orders that are still in progress in your old system need to come with you. Keying them in by hand is slow, and with hundreds of orders it is easy to miss an item, put an order on the wrong customer or create the same order twice.
The sales order import lets your own system send those orders straight into The Layer, and it is built to be safe to run in bulk:
Checked first: each order is checked in full before anything is saved, and every problem is listed in one reply.
All or nothing: an order is created completely, with all its items, or not at all.
No duplicates: sending the same order again returns the order made the first time.
Your normal process: imported orders start at the beginning of your order process, like any order created on screen.
Orders, not assets
The import creates sales orders and their items. It does not create assets. Assets are created later, when an order is completed, and only for items marked as New. Services your customers already have should come in through your asset import, not through orders.
How it works
Your system groups its data by order number and sends one request per order. The import builds the order the same way The Layer builds one on screen:
The sales order: the customer, owner, dates and purchase order number.
Lines: each line is a product from your Inventory with a quantity and prices.
Units: each line has one data capture row per unit, holding that unit's details (for example its CLI, serial or IMEI) and how it links to other units.
Before you start
Load your customers, contacts, sites and products first. Every order must match a customer in The Layer and every line a product in your Inventory.
Load live services through your asset import, including any service an order upgrades or replaces. An order can only point at an asset that is already in The Layer.
Create an API application and tokens for the user that will run the import. See Authenticating API Requests for The Layer.
Give that user the API - Sales Order Import permission: go to Settings > Users, open the user, open the Roles tab, find Developer API, tick API - Sales Order Import and click Save. See User-Based API Permissions.
API - Access All Areas does not include the import. Because it creates orders in bulk, it needs its own permission, even for a user who already has full API access.
We recommend trying the import on a test company first. Each order is checked and created exactly as it will be for real.
The calls
All three calls are on https://webapi.thelayer.com and need the Token1 and Token2 headers, like every Layer API call.
Call | What it does |
| Runs every check and saves nothing. Use it to clean your data before the real run. |
| Creates the order, its lines and its data capture rows. |
| Tells you what happened to an order you sent. |
Building a request
This example is one order for one customer with three lines: two connections, a handset tied to the first connection, and two data bolt-ons that sit under the connections. The second connection upgrades a service the customer already has (asset 900).
{
"ExternalReference": "SO-1001",
"CustomerLookupField": "Reference",
"CustomerLookupValue": "CUS0001",
"Owner": "jane.smith",
"OrderDate": "2026-10-01",
"CustomerPO": "PO-778",
"Lines": [
{
"LineKey": "CONN", "ProductSKU": "MOB-CONN", "Quantity": 2, "RecurringCost": 18.50,
"Units": [
{ "UnitKey": "C1", "Action": "New", "ServiceMSISDN": "07700900001", "LinkedProductUnitKey": "H1" },
{ "UnitKey": "C2", "Action": "Update", "TargetAssetId": 900, "ServiceMSISDN": "07700900123" }
]
},
{
"LineKey": "PHONE", "ProductSKU": "HANDSET", "Quantity": 1,
"Units": [ { "UnitKey": "H1", "Action": "New", "ProductIMEI": "350000000000001" } ]
},
{
"LineKey": "BOLT", "ParentLineKey": "CONN", "ProductSKU": "DATA-BOLT", "Quantity": 2,
"Units": [ { "Action": "New" }, { "Action": "New" } ]
}
]
}Order fields
Field | Required | Notes |
| Yes | Your order number, up to 100 characters, unique within your company. It is what makes sending an order again safe. |
| One of these | The customer's id in The Layer. |
| One of these | Find the customer by |
| No | One of the customer's contacts. |
| No | One of the customer's sites. It sets the order's delivery and billing addresses. |
| No | One of your sub companies. |
| No | The username of the order owner. Defaults to the API user. |
| No | The date the order was raised in your old system. Defaults to today. |
| No | Defaults to today plus your usual fulfilment lead time. |
| No | The customer's purchase order number. |
| No | Defaults to |
| Yes | At least one line. |
There is no status field. Every imported order starts at your company's starting sales order status, whatever its status was in your old system, so it goes through your order process from the beginning.
Line fields
Field | Required | Notes |
| Yes | Your id for the line, unique within the order. It is used in replies and by |
| Yes, one of them | The product in your Inventory. A SKU must match exactly one live product. |
| Yes | From 1 to 2,000. |
| No | One-off sell and buy price for each unit. Default to the product's. |
| No | Monthly sell and buy price for each unit. Default to the product's. |
| No | The term in months. Defaults to the product's. |
| No | Changes the name shown on the line. |
| No | One of the product's active classifications. |
| No | One of the customer's sites. |
| No | A note shown on the line. |
| No | Links this line's units under another line's units. See Linking units together. |
| No | Up to the line's quantity. Units you leave out are created blank, as they are when an order is made on screen. |
Unit fields
Field | Required | Notes |
| Only if another unit links to it | Your id for the unit, unique within the order. |
| No |
|
| For | The id of the existing service the unit changes or replaces. |
| No | The service unit this unit sits under. |
| No | The hardware unit this unit is tied to. |
| No | The unit's connection date. |
| No | The unit's details, as you would enter them in data capture. |
Only New units become assets. If a service is already live and came in through your asset import, send its unit as No Action, or completing the order will create it a second time.
Products sold as one grouped quantity
Some products are set up so the whole quantity is one item, for example a block of DDIs or a pack of licences (the product's Quantity Mode is Grouped). For these, the line has a single data capture row that holds the whole quantity and becomes one asset. Send one unit for the line, with the details that apply to the whole block.
Linking units together
Links decide how assets fit together when the order completes, so send them explicitly. Nothing is worked out from product names.
Link | Field | What it does |
Parent service |
| Puts a service under another service, for example a bolt-on under its connection. The bolt-on's asset becomes a child of the connection's asset. |
Hardware |
| Ties a service to a hardware unit, for example a connection to its handset. The handset takes the connection's user, cost centre and site. |
Existing asset |
| The live asset an |
The rules are the same as on the data capture screen:
Only service units link to a parent or to hardware. A parent must be a service, and a hardware link must point at hardware.
Links stay within one base category, and they can't go round in a loop.
A target asset must be live, belong to the order's customer and be in the same base category as the product. Two units can't target the same asset.
Linking a whole line with ParentLineKey
If a line has ParentLineKey and its units have no LinkedParentUnitKey of their own, they are linked to the parent line's units in turn. Two bolt-ons under two connections go one each; three bolt-ons under two connections go to connection 1, 2 and then 1 again, as the auto map on the data capture screen does. The parent line must be a service line in the same base category that does not have a ParentLineKey itself. The order lines themselves are not nested: the links are on the units, which is what builds the assets.
If two products are linked on the order but are not set up as linked products in your Inventory, the order keeps the link and the reply includes a warning. Inventory links only affect what quotes suggest.
What you get back
Every reply includes Outcome, ExternalReference, SalesOrderId, Reference (the order's number in The Layer, for example SO1000), Errors and Warnings. After an import it also includes Lines: your line and unit keys with the ids created for them.
HTTP | Outcome | Meaning | What to do |
200 |
| Validate only: the order would be accepted. | Check any warnings. |
201 |
| The order was created. | Keep |
200 |
| This | Nothing: no second order was made. |
400 |
| Nothing was saved. Every problem is listed in | Fix the data and send it again. |
409 |
| Another call with this reference is still running. | Wait, then call Status. |
500 |
| Nothing was saved and the reference was released. | Safe to send again. |
500 |
| The order was created but did not finish. The reference stays taken. | Don't send it again. Contact us with the reference. |
Each error says where the problem is, so you can go straight to it:
{ "Path": "Lines[2].Units[0].LinkedParentUnitKey",
"Message": "A linked parent must be a service; 'H1' is Handset, which is hardware. Use LinkedProductUnitKey for hardware." }Running the load
Validate every order and fix your data until they all come back
Valid.Import one order at a time.
Allow time for big orders. An order with several hundred units can take a minute or more. Set your client's timeout to at least 5 minutes.
If a call times out or you're not sure it went through, call Status, or simply send the order again. You'll get
AlreadyImportedorInProgress, never a second order.If you get
Partial, stop sending that order and let us know its reference.
Good to know
Starting status: imported orders always start at your company's starting sales order status.
Automations: automations and scripts that normally run when an order is created (for example raising a case for time tracking, or a customer sync to a billing platform) do not run for imported orders. If you set
RunCreateScriptstotrue, all of them run, exactly as for an order created on screen.Prices: each line takes the product's prices unless you send your own.
Text is cleaned: as on every Layer API call, anything that looks like an HTML tag is removed from text values, and so are prefixes such as
javascript:anddata:. A note ofData: 10GB <b>bolt-on</b>is stored as10GB bolt-on. Keep free text plain.Ceases: a sales order does not cease a service on its own. To cease services that are already in The Layer, use the cease request import in Data Manager, which takes an asset and a cease date. See Using Data Manager to Import Records.
Limits: one order per call, up to 1,000 lines and 2,000 units (the total of the line quantities). Normal API rate limits apply.
Troubleshooting
You see | What it means | What to do |
400 "Missing Authorization-Token" | The tokens are missing, wrong or expired. | Check the |
400 "User not authorised to access WebAPI" | The API user does not have the import permission. | Tick API - Sales Order Import on the user's Roles tab. |
"No customer has Reference ..." or "More than one customer has ..." | The customer lookup matched none, or more than one. | Check the value, or send |
"No product has SKU ..." or "2 products have SKU ..." | The SKU isn't in your Inventory, or is on more than one product. | Add or fix the product, or send |
"Contact ... is not a contact of this customer" or "Site ... is not a site of this customer" | The contact or site belongs to someone else. | Use the customer's own contact or site, or leave it out. |
"Asset ... is not live", "is not a service of this customer" or "is in a different base category" | The target asset can't be changed by this unit. | Check the asset id and that the asset is loaded and live. |
"Update is switched off ..." or "New & Cease is not switched on ..." | Your company's data capture doesn't offer that action. | Use |
"A linked parent must be a service ..." or "Linked parents form a loop" | A link points the wrong way or goes round in a circle. | See Linking units together. |
"User ... was not found" | The | Use their username in The Layer, or leave it out. |

