Send a UK import declaration to CDS from an invoice
This recipe takes a commercial invoice and packing list and ends with an MRN from HMRC. It reads the documents with AI, a person corrects them beside the originals, and Send CDS declaration builds, checks and sends an H1 import declaration.
For the declaration that completes a simplified declaration or an entry in your records, see Send a supplementary declaration. For exports, see Send a UK export declaration.
A person stays in the path twice: once to review what was read from the documents, and again if the declaration fails a check or HMRC rejects it.
Where you can send it from
Section titled “Where you can send it from”Lainstack sends the declaration straight to HMRC. HMRC asks for imports at ports and airports with their own cargo systems to go through that port’s system instead, so this recipe fits roll-on roll-off ports, inland locations and ports without such a system. HMRC’s sandbox doesn’t check this.
1. Connect HMRC
Section titled “1. Connect HMRC”Add the HMRC Customs Declarations connection and click Connect. If it asks for an HMRC environment, choose Sandbox (Trader Dress Rehearsal). See Connect your systems.
2. Set up the two tables
Section titled “2. Set up the two tables”The block fills most of a declaration from standing data, so nobody retypes it for each shipment. Create two reference tables:
| Table | Key columns | Also holds |
|---|---|---|
| Clients | client_key, exactly one row per client |
eori (the importer), declarant_eori, representation_code, method_of_payment, and any deferment account or authorisations |
| Products | product_key, client_key |
description, aliases, commodity_code, taric_code, supplementary_unit |
A client with more than one row in the client table stops the block.
How the client pays duty is its method_of_payment:
| Code | Pays by | Also needs |
|---|---|---|
E |
Deferment account | deferment_account, the DPO and CGU authorisations and the guarantee columns |
P |
CDS cash account | Nothing; cash_account_eori when the account belongs to someone else |
H |
Immediate payment by bank transfer | Nothing |
For goods going into a private customs warehouse, also fill in warehouse_id (the warehouse type and number, such as U1234567GB) and cwp_authorisation.
3. Read the documents
Section titled “3. Read the documents”Start the automation with an Operation form that takes the files, then read them as in Read data from a document. The answer needs the invoice’s number and date, the exporter, the Incoterm and its place, the currency and the lines.
To catch bad codes first, add the commodity code check here.
4. Have a person correct what was read
Section titled “4. Have a person correct what was read”Add an Approval with the answer as Data to review, Reviewer can set to Correct the data, and the files as Source documents.
5. Send the declaration
Section titled “5. Send the declaration”Add Send CDS declaration with Declaration set to Import:
- Invoice data: the Approval’s Reviewed data.
- Source documents: the files, shown beside the declaration if it needs fixing.
- Client, Client table and Product table: from step 2.
- Type: Goods have arrived (IMA), or Before arrival, pre-lodged (IMD).
- Procedure: Release to free circulation (4000), or Customs warehousing (7100), which declares no tax lines.
- Wait until: Accepted (MRN issued), or Released (goods cleared) to wait for release. A pre-lodged (IMD) declaration also offers Received (MRN issued), which continues once HMRC has it, before the goods arrive: HMRC accepts it only on arrival. Use it when a later step arrives the goods, as a GMR does on a GVMS route.
- Give up after (minutes): defaults to 15, and can go up to 14 days.
6. Connect every exit
Section titled “6. Connect every exit”| Exit | What it means | What to do with it |
|---|---|---|
| Accepted | HMRC reached the point you chose under Wait until. MRN holds the reference | Record the MRN in your own system |
| Held by customs | Customs is holding the goods for a control or documents. Only with Released | Send the documents or assign the hold |
| Timed out | No decision within Give up after | Check the status later |
| Rejected in review | A reviewer rejected the declaration | Tell whoever owns the shipment |
7. Answer a hold
Section titled “7. Answer a hold”When customs asks for documents (DMSDOC), add Upload documents to HMRC on Held by customs, with the MRN from the send block and the documents as Files. It waits until HMRC has checked every file. A case worker then reviews them, so follow the declaration with Get CDS declaration status. Answer a customs hold with documents walks through it.
8. Arrive, amend or cancel
Section titled “8. Arrive, amend or cancel”Add Update CDS declaration with the same connection and the MRN, and choose the Action:
- Goods have arrived: for a pre-lodged (IMD) declaration, once the goods are at the goods location. Until then HMRC does not accept or clear it.
- Amend the declaration: after acceptance, when something was wrong. Also set Declaration record from the send block’s output. A reviewer changes the fields in the same review the send block opens for rejections, and HMRC receives only what changed, with your Reason.
- Cancel the declaration: before clearance, with a Reason.
It leaves on Done, Refused (rejected or denied by HMRC, with the reasons) or Timed out. See Amend or cancel a CDS declaration.
What goes wrong
Section titled “What goes wrong”- The declaration fails a check. It is checked against CDS rules and HMRC’s XSD schemas before anything is sent. Errors open a document review where a reviewer fixes the fields, and the block sends with their changes. Errors no field can fix fail the step.
- HMRC refuses or rejects it. A review opens here too, and a resend uses a new LRN.
- HMRC is slow or down on send. Rate limits, timeouts and server errors fail the step.
- You resume a run. A run that was waiting on HMRC goes back to checking. Any other resume sends again under a new LRN, keeping the reviewers’ changes, so check first that the earlier send didn’t land.
Test it
Section titled “Test it”A draft run holds this block on every connection, so nothing is built, checked or sent. To test it, publish the automation and run it against the sandbox connection. The declaration XML and its record are saved as run files. A production connection needs the trader to sign in with Government Gateway using an EORI enrolled for CDS. Run your own declarations through the sandbox before you move across.