opencollection: 1.0.0
info:
  name: Trader Transition API Collection
config:
  proxy:
    inherit: true
    config:
      protocol: http
      hostname: ''
      port: ''
      auth:
        username: ''
        password: ''
      bypassProxy: ''
  environments:
    - name: tss_tradertest
      variables:
        - name: baseURL
          value: https://tt.nc-tss.uk/api/v1/trader_api/transition
        - name: clientID
          value: ''
        - name: token_URL
          value: https://auth.tt.nc-tss.uk/realms/TSS_Portal/protocol/openid-connect/token
        - name: scope
          value: openid roles
        - name: carrier_eori
          value: ''
        - name: haulier_eori
          value: ''
        - name: importer_eori
          value: ''
        - name: exporter_eori
          value: ''
        - name: consignor_eori
          value: ''
        - name: env
          value: tt
        - name: consignee_eori
          value: ''
        - name: sfd_gb_carrier_eori
          value: ''
        - name: sup_dec_gb_carrier_eori
          value: ''
        - name: sup_dec_gb_exporter_eori
          value: ''
        - name: clientSecret
          secret: true
items:
  - info:
      name: Trader Transition API Specification
      type: folder
      seq: 1
    request:
      auth: inherit
    items:
      - info:
          name: Agent Relationship
          type: folder
          seq: 1
        request:
          auth: inherit
        items:
          - info:
              name: Read Agent ActAs
              type: http
              seq: 2
            http:
              method: GET
              url: '{{baseURL}}/headers?reference={{lrn}}&actAs={{customer_account_sys_id}}&fields=status,movement_type'
              params:
                - name: reference
                  value: '{{lrn}}'
                  type: query
                - name: actAs
                  value: '{{customer_account_sys_id}}'
                  type: query
                - name: fields
                  value: status,movement_type
                  type: query
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Read Agent Relationship
              type: http
              seq: 13
            http:
              method: GET
              url: '{{baseURL}}/agent_relationships'
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
      - info:
          name: ENS Consignment
          type: folder
          seq: 2
        request:
          auth: inherit
        items:
          - info:
              name: Cancel Consignment
              type: http
              seq: 3
            http:
              method: POST
              url: '{{baseURL}}/consignments'
              body:
                type: json
                data: |-
                  {
                    "op_type": "cancel",
                    "consignment_number": "{{dec_lrn_01}}"
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Create Consignments
              type: http
              seq: 1
            http:
              method: POST
              url: '{{baseURL}}/consignments'
              body:
                type: json
                data: |
                  {
                    "op_type": "create",
                    "declaration_number": "{{ens_lrn_01}}",
                    "consignment_number": "",
                    "goods_description": "Cotton sheets",
                    "trader_reference": "XX0001",
                    "transport_document_number": "21321",
                    "controlled_goods": "no",
                    "goods_domestic_status": "D",
                    "supervising_customs_office": "",
                    "customs_warehouse_identifier": "",
                    "ducr": "",
                    "consignor_eori": "{{consignor_eori}}",
                    "consignor_name": "",
                    "consignor_street_number": "",
                    "consignor_city": "",
                    "consignor_postcode": "",
                    "consignor_country": "GB",
                    //"consignee_eori": "",
                    "consignee_name": "Fred Bloggs",
                    "consignee_street_number": "423 Falls Road",
                    "consignee_city": "Belfast",
                    "consignee_postcode": "BT1 1BG",
                    "consignee_country": "GB",
                    "importer_eori": "{{importer_eori}}",
                    "buyer_same_as_importer": "yes",
                    "exporter_eori": "{{exporter_eori}}",
                    "seller_same_as_exporter": "no",
                    //"seller_eori": "",
                    "seller_name": "Seller Name",
                    "seller_street_and_number": "45 Mosley Street",
                    "seller_city": "Manchester",
                    "seller_postcode": "M1 1AJ",
                    "seller_country": "GB",
                    "exporter_name": "",
                    "exporter_street_number": "",
                    "exporter_city": "",
                    "exporter_postcode": "",
                    "exporter_country": "GB",
                    "container_indicator": "1",
                    "header_previous_document": [],
                    "holder_of_authorisation": [
                      {
                        "op_type": "create",
                        "auth_role_id": "GB000000000001",
                        "auth_type_code": "CW1"
                      }
                    ]
                  }
              auth: inherit
            runtime:
              actions:
                - type: set-variable
                  phase: after-response
                  selector:
                    expression: res.body.result.reference
                    method: jsonq
                  variable:
                    name: dec_lrn_01
                    scope: runtime
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Read Consignment
              type: http
              seq: 4
            http:
              method: GET
              url: |-
                {{baseURL}}/consignments?reference={{dec_lrn_01}}&fields=status,transport
                _document_number,consignor_eori,sfd_number,error_message,importer_eori,holder_of_authorisation
              params:
                - name: reference
                  value: '{{dec_lrn_01}}'
                  type: query
                - name: fields
                  value: |-
                    status,transport
                    _document_number,consignor_eori,sfd_number,error_message,importer_eori,holder_of_authorisation
                  type: query
              body:
                type: json
                data: ''
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Submit Consignment
              type: http
              seq: 2
            http:
              method: POST
              url: '{{baseURL}}/consignments'
              body:
                type: json
                data: |-
                  {
                    "op_type": "submit",
                    "consignment_number": "{{dec_lrn_01}}"
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Update Consignment
              type: http
              seq: 5
            http:
              method: POST
              url: '{{baseURL}}/consignments'
              body:
                type: json
                data: |-
                  {
                    "op_type": "update",
                    "declaration_number": "",
                    "consignment_number": "{{dec_lrn_01}}",// Required for update request
                    "goods_description": "Wooden Furnitures",
                    "trader_reference": "XX0001",
                    "transport_document_number": "21321",
                    "controlled_goods": "no",
                    "goods_domestic_status": "D",
                    "supervising_customs_office": "",
                    "customs_warehouse_identifier": "",
                    "ducr": "",
                    "consignor_eori": "{{consignor_eori}}",
                    "consignor_name": "",
                    "consignor_street_number": "",
                    "consignor_city": "",
                    "consignor_postcode": "",
                    "consignor_country": "GB",
                    //"consignee_eori": "",
                    "consignee_name": "Fred Bloggs",
                    "consignee_street_number": "423 Falls Road",
                    "consignee_city": "Belfast",
                    "consignee_postcode": "BT1 1AA",
                    "consignee_country": "GB",
                    "importer_eori": "{{importer_eori}}",
                    "buyer_same_as_importer": "yes",
                    "exporter_eori": "{{exporter_eori}}",
                    "seller_same_as_exporter": "no",
                    //"seller_eori": "",
                    "seller_name": "Seller Name",
                    "seller_street_and_number": "45 Mosley Street",
                    "seller_city": "Manchester",
                    "seller_postcode": "M1 1AJ",
                    "seller_country": "GB",
                    "exporter_name": "",
                    "exporter_street_number": "",
                    "exporter_city": "",
                    "exporter_postcode": "",
                    "exporter_country": "GB",
                    "container_indicator": "1",
                    "holder_of_authorisation": [
                      {
                        "op_type": "update",
                        "auth_role_id": "GB000000000001",
                        "auth_type_code": "CW1"
                      }
                    ]
                  }
              auth: inherit
            runtime:
              variables:
                - name: consignor_eori
                  value: XI171809009000
                - name: importer_eori
                  value: XI171809009000
                - name: exporter_eori
                  value: XI171809009000
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
      - info:
          name: Declaration
          type: folder
          seq: 12
        request:
          auth: inherit
        items:
          - info:
              name: Cancel  Declaration Header
              type: http
              seq: 3
            http:
              method: POST
              url: '{{baseURL}}/headers'
              body:
                type: json
                data: |-
                  {
                    "op_type": "cancel",
                    "declaration_number": "{{ens_lrn_10}}"
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Create Declaration Header
              type: http
              seq: 4
            http:
              method: POST
              url: '{{baseURL}}/headers'
              body:
                type: json
                data: |-
                  {
                    "op_type": "create",
                    "declaration_number": "", // Specify the declaration number to update
                    "movement_type": "3a",
                    "type_of_passive_transport": "3121",
                    //Yes, If movement_type = ‘RoRo Accompanied’ (3a)
                    "identity_no_of_transport": "IMO1234567#B1234567",
                    "nationality_of_transport": "GB",
                    "conveyance_ref": "",
                    "arrival_date_time":"{{arrival_date_time}}",
                    "arrival_port": "GBAUBELBELGVM",
                    "place_of_loading": "Birkenhead",
                    "place_of_acceptance_same_as_loading": "yes",
                    "place_of_acceptance": "",
                    "place_of_unloading": "Belfast",
                    "place_of_delivery_same_as_unloading": "yes",
                    "place_of_delivery": "",
                    "seal_number": "s123756",
                    "route": "gb-ni",
                    "transport_charges": "Y",
                    "carrier_eori": "{{carrier_eori}}",
                    "carrier_name": "Carrier Name",
                    "carrier_street_number": "10",
                    "carrier_city": "London",
                    "carrier_postcode": "SW1A 1AA",
                    "carrier_country": "GB",
                    "haulier_eori": "{{haulier_eori}}"
                  }
              auth: inherit
            runtime:
              scripts:
                - type: before-request
                  code: |-
                    // 1. Get the current time
                    const date = new Date();

                    // 2. Add X hours (X * 60 minutes * 60 seconds * 1000 milliseconds)
                    const additionalHoursInMs = 5 * 60 * 60 * 1000;
                    const futureDate = new Date(date.getTime() + additionalHoursInMs);

                    // 3. Extract UTC components for this future time
                    const day = String(futureDate.getUTCDate()).padStart(2, '0');
                    const month = String(futureDate.getUTCMonth() + 1).padStart(2, '0');
                    const year = futureDate.getUTCFullYear();

                    const hours = String(futureDate.getUTCHours()).padStart(2, '0');
                    const minutes = String(futureDate.getUTCMinutes()).padStart(2, '0');
                    const seconds = String(futureDate.getUTCSeconds()).padStart(2, '0');

                    // 4. Format as DD/MM/YYYY HH:mm:ss
                    const formattedFutureGmtZero = `${day}/${month}/${year} ${hours}:${minutes}:${seconds}`;

                    // 5. Save to a new variable
                    bru.setVar("arrival_date_time", formattedFutureGmtZero);
              actions:
                - type: set-variable
                  phase: after-response
                  selector:
                    expression: res.body.result.reference
                    method: jsonq
                  variable:
                    name: ens_lrn_10
                    scope: runtime
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Read Declaration Header
              type: http
              seq: 1
            http:
              method: GET
              url: |-
                {{baseURL}}/headers?reference={{ens_lrn_10}}&fields=status,arrival_port,se
                al_number,route,carrier_eori
              params:
                - name: reference
                  value: '{{ens_lrn_10}}'
                  type: query
                - name: fields
                  value: |-
                    status,arrival_port,se
                    al_number,route,carrier_eori
                  type: query
              body:
                type: json
                data: ''
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Update Declaration Header
              type: http
              seq: 2
            http:
              method: POST
              url: '{{baseURL}}/headers'
              body:
                type: json
                data: |-
                  {
                    "op_type": "update",
                    "declaration_number": "{{ens_lrn_10}}", // Specify the declaration number to update
                    "movement_type": "3a",
                    "type_of_passive_transport": "3121",
                    //Yes, If movement_type = ‘RoRo Accompanied’ (3a)
                    "identity_no_of_transport": "IMO1234567#B1234567",
                    "nationality_of_transport": "GB",
                    "conveyance_ref": "",
                    "arrival_date_time":"{{arrival_date_time}}",
                    "arrival_port": "GBAUBELBELGVM",
                    "place_of_loading": "Birkenhead",
                    "place_of_acceptance_same_as_loading": "yes",
                    "place_of_acceptance": "",
                    "place_of_unloading": "Belfast",
                    "place_of_delivery_same_as_unloading": "yes",
                    "place_of_delivery": "",
                    "seal_number": "s123756",
                    "route": "gb-ni",
                    "transport_charges": "Y",
                    "carrier_eori": "{{carrier_eori}}",
                    "carrier_name": "Carrier Name",
                    "carrier_street_number": "10",
                    "carrier_city": "London",
                    "carrier_postcode": "SW1A 1AA",
                    "carrier_country": "GB",
                    "haulier_eori": "{{haulier_eori}}"
                  }
              auth: inherit
            runtime:
              scripts:
                - type: before-request
                  code: |-
                    // 1. Get the current time
                    const date = new Date();

                    // 2. Add X hours (X * 60 minutes * 60 seconds * 1000 milliseconds)
                    const additionalHoursInMs = 5 * 60 * 60 * 1000;
                    const futureDate = new Date(date.getTime() + additionalHoursInMs);

                    // 3. Extract UTC components for this future time
                    const day = String(futureDate.getUTCDate()).padStart(2, '0');
                    const month = String(futureDate.getUTCMonth() + 1).padStart(2, '0');
                    const year = futureDate.getUTCFullYear();

                    const hours = String(futureDate.getUTCHours()).padStart(2, '0');
                    const minutes = String(futureDate.getUTCMinutes()).padStart(2, '0');
                    const seconds = String(futureDate.getUTCSeconds()).padStart(2, '0');

                    // 4. Format as DD/MM/YYYY HH:mm:ss
                    const formattedFutureGmtZero = `${day}/${month}/${year} ${hours}:${minutes}:${seconds}`;

                    // 5. Save to a new variable
                    bru.setVar("arrival_date_time", formattedFutureGmtZero);
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
      - info:
          name: GMR
          type: folder
          seq: 4
        request:
          auth: inherit
        items:
          - info:
              name: Cancel GMR
              type: http
              seq: 5
            http:
              method: POST
              url: '{{baseURL}}/gvms_gmr'
              body:
                type: json
                data: |-
                  {
                    "op_type": "cancel",
                    "gmr_lrn": "{{active_gmr}}"
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Create GMR
              type: http
              seq: 1
            http:
              method: POST
              url: '{{baseURL}}/gvms_gmr'
              body:
                type: json
                data: |-
                  {
                    "op_type": "create",
                    "ens_lrn": "{{ens_lrn_01}}",
                    "route_id": "2",
                    "is_unaccompanied": "no",
                    "vehicle_reg_num": "TA48HXY",
                    "trailer_registration_nums": ["TA48HXZ"],
                    "external_contacts": [
                      {
                        "op_type": "create",
                        "contact_email": "email@domain.com"
                      }
                    ]
                  }
              auth: inherit
            runtime:
              actions:
                - type: set-variable
                  phase: after-response
                  selector:
                    expression: res.body.result.reference
                    method: jsonq
                  variable:
                    name: active_gmr
                    scope: runtime
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Read GMR
              type: http
              seq: 4
            http:
              method: GET
              url: |-
                {{baseURL}}/gvms_gmr?reference=GMR#&fields=route_id,
                direction, ens_lrn,gmr_lrn, vehicle_reg_num, trailer_registration_nums, gmr_id, gmr_status, error_reason, inspection_required,
                report_to_locations
              params:
                - name: reference
                  value: GMR#
                  type: query
                - name: fields
                  value: |-
                    route_id,
                    direction, ens_lrn,gmr_lrn, vehicle_reg_num, trailer_registration_nums, gmr_id, gmr_status, error_reason, inspection_required,
                    report_to_locations
                  type: query
              body:
                type: json
                data: ''
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Submit GMR
              type: http
              seq: 3
            http:
              method: POST
              url: '{{baseURL}}/gvms_gmr'
              body:
                type: json
                data: |-
                  {
                    "op_type": "submit",
                    "gmr_lrn": "{{active_gmr}}"
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Update GMR
              type: http
              seq: 2
            http:
              method: POST
              url: '{{baseURL}}/gvms_gmr'
              body:
                type: json
                data: |-
                  {
                    "op_type": "update",
                    "gmr_lrn": "{{active_gmr}}",
                    "route_id": "2",
                    "is_unaccompanied": "no",
                    "vehicle_reg_num": "LA21VVX",
                    "trailer_registration_nums": ["TA48HXY", "AA32XZY"]
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
      - info:
          name: Goods Items
          type: folder
          seq: 5
        request:
          auth: inherit
        items:
          - info:
              name: Create Goods Items
              type: http
              seq: 3
            http:
              method: POST
              url: '{{baseURL}}/goods'
              body:
                type: json
                data: |-
                  {
                    "op_type": "create",
                    "consignment_number": "{{dec_lrn_01}}",
                    "goods_id": "",
                    "equipment_number": "AAAA9999991",
                    "un_dangerous_goods_code": "",
                    "type_of_packages": "boxes",
                    "number_of_packages": "20",
                    "number_of_individual_pieces": "",
                    "package_marks": "ADDR",
                    "gross_mass_kg": "1210",
                    "net_mass_kg": "1000",
                    "goods_description": "Wooden Artifacts 1",
                    "invoice_number": "0000765455",
                    "controlled_goods": "no",
                    "controlled_goods_type": "",
                    "commodity_code": "340520",
                    "country_of_origin": "GB",
                    "item_invoice_amount": "1500.00",
                    "item_invoice_currency": "GBP",
                    "procedure_code": "4000",
                    "additional_procedure_code": "000",
                    "taric_code": "",
                    "cus_code": "",
                    "national_additional_code": "",
                    "ni_additional_information_codes": "NONE",
                    "supplementary_units": "1",
                    "tax_base_unit": "",
                    "tax_base_quantity": "",
                    "nature_of_transaction": "1",
                    "preference": "100",
                    // "valuation_method":"1",
                    // "valuation_indicator":"0000",
                    "additional_procedures": [],
                    "document_references": [],
                    "additional_information": [
                      {
                        "op_type": "create",
                        "additional_info_code": "NIDOM",
                        "additional_info_description": ""
                      }
                    ],
                    "detail_previous_document": [],
                    "item_add_ded": [],
                    "national_additional_codes": []
                  }
              auth: inherit
            runtime:
              actions:
                - type: set-variable
                  phase: after-response
                  selector:
                    expression: res.body.result.reference
                    method: jsonq
                  variable:
                    name: goods_id_01
                    scope: runtime
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Delete Goods Items
              type: http
              seq: 4
            http:
              method: POST
              url: '{{baseURL}}/goods'
              body:
                type: json
                data: |-
                  {
                    "op_type": "delete",
                    "goods_id": "{{goods_id_01}}"
                  }
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Lookup Goods Items
              type: http
              seq: 1
            http:
              method: GET
              url: '{{baseURL}}/goods'
              params:
                - name: sup_dec_number
                  value: SUP#
                  type: query
                  disabled: true
                - name: ens_number
                  value: ENS#
                  type: query
                  disabled: true
                - name: sfd_number
                  value: DEC#
                  type: query
                  disabled: true
                - name: ffd_number
                  value: FFD#
                  type: query
                  disabled: true
                - name: glr_number
                  value: GLR#
                  type: query
                  disabled: true
              body:
                type: json
                data: ''
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Read Goods Items
              type: http
              seq: 5
            http:
              method: GET
              url: |-
                {{baseURL}}/goods?fields=country_of_origin,commodity_code,gross_weight_kg,comm
                odity_code,document_references,item_invoice_amount,gross_mass_kg,equipment_number,net_mass_kg,additional_information,item_add_ded&reference={{goods_id_01}}
              params:
                - name: fields
                  value: |-
                    country_of_origin,commodity_code,gross_weight_kg,comm
                    odity_code,document_references,item_invoice_amount,gross_mass_kg,equipment_number,net_mass_kg,additional_information,item_add_ded
                  type: query
                - name: reference
                  value: '{{goods_id_01}}'
                  type: query
              body:
                type: json
                data: ''
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Update Goods Items
              type: http
              seq: 2
            http:
              method: POST
              url: '{{baseURL}}/goods'
              body:
                type: json
                data: |-
                  {
                    "op_type": "update",
                    //"consignment_number": "",
                    "goods_id": "{{goods_id_01}}", //specify the goods id of the consignment to update
                    "equipment_number": "AAAA9999991",
                    "type_of_packages": "boxes",
                    "gross_mass_kg": "1400",
                    "net_mass_kg": "1000",
                    "goods_description": "Wooden Artifacts 1",
                    "invoice_number": "0000765455",
                    "country_of_preferential_origin": "",
                    "nature_of_transaction": "1",
                    "preference": "100",
                    "item_invoice_amount": "1500.00",
                    "procedure_code": "4000",
                    "additional_procedure_code": "000",
                    "valuation_method": "1",
                    "valuation_indicator": "0000",
                    "ni_additional_information_codes": "NIREM",
                    "supplementary_units": "1",
                    "country_of_origin": "GB",
                    "number_of_packages": "10",
                    "package_marks": "ADDR",
                    "commodity_code": "0105130000",
                    "item_invoice_currency": "GBP"
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
      - info:
          name: Internal Market Movement Information
          type: folder
          seq: 6
        request:
          auth: inherit
        items:
          - info:
              name: Cancel IMMI Standalone
              type: http
              seq: 4
            http:
              method: POST
              url: '{{baseURL}}/internal_market_movement'
              body:
                type: json
                data: |-
                  {
                    "op_type": "cancel",
                    "glr_number": "{{glr_lrn_01}}"
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Create IMMI Standalone
              type: http
              seq: 1
            http:
              method: POST
              url: '{{baseURL}}/internal_market_movement'
              body:
                type: json
                data: |-
                  {
                    "op_type": "create",
                    "glr_number": "",
                    "declaration_category": "IMD",
                    "representation_type": "2",
                    "free_circulation_home_uses": "Yes",
                    "mode_of_transport": "3",
                    "icr": "",
                    "maritime_inventory": "",
                    "house_airway_bill": "",
                    "arrival_date_time": "{{arrival_date_time}}",
                    "internal_market": "confirmed",
                    "importer_eori": "{{importer_eori}}",
                    "exporter_eori": "{{exporter_eori}}",
                    "exporter_name": "",
                    "exporter_city": "",
                    "exporter_postcode": "",
                    "exporter_country": "GB",
                    "exporter_street_number": "",
                    "location_of_goods_border": "GBAUDYLBFSAGE",
                    "location_of_goods_other": "",
                    "customs_warehouse_identifier": "",
                    "transport_document_reference": "101101",
                    "trader_reference": "GLR Test",
                    "transport_document_type": "N730",
                    "location_of_goods_border": "GBAUBELBFSBEL",
                    "holder_of_authorisation": [
                      {
                        "op_type": "create",
                        "auth_role_id": "23",
                        "auth_role_type": "",
                        "auth_type_code": "TST"
                      }
                    ],
                    "header_previous_document": [
                      {
                        "op_type": "create",
                        "previous_document_class": "X",
                        "previous_document_item_identifier": "101",
                        "previous_document_ref": "1234",
                        "previous_document_type": "235"
                      }
                    ]
                  }
              auth: inherit
            runtime:
              scripts:
                - type: after-response
                  code: |-
                    const moment = require('moment');

                    const arrival = moment()
                      .add(60, 'minutes')
                      .format('DD/MM/YYYY HH:mm:ss');

                    bru.setVar('arrival_date_time', arrival);
              actions:
                - type: set-variable
                  phase: after-response
                  selector:
                    expression: res.body.result.reference
                    method: jsonq
                  variable:
                    name: glr_lrn_01
                    scope: runtime
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Create SPIMM Goods Items
              type: http
              seq: 9
            http:
              method: POST
              url: '{{baseURL}}/goods'
              body:
                type: json
                data: |-
                  {
                    "op_type": "create",
                    "consignment_number": "{{glr_lrn_01}}",
                    "goods_id": "",
                    "commodity_code": "2301100000",
                    "procedure_code": "4000",
                    "additional_procedure_code": "1EL",
                    "country_of_origin": "GB",
                    "ni_additional_information_codes": "NIREM",
                    "goods_description": "Testing",
                    "gross_mass_kg": "100",
                    "net_mass_kg": "100",
                    "item_invoice_amount": "157.00",
                    "item_invoice_currency": "gbp",
                    "supplementary_units": "",
                    "number_of_packages": "10",
                    "document_references": [
                      {
                        "op_type": "create",
                        "document_code": "9101",
                        "document_reference": "Testing DR",
                        "document_status": "JP",
                        "document_part": "",
                        "document_reason": "TEST",
                        "date_of_validity": "",
                        "issuing_authority": "",
                        "amount": "",
                        "currency": "",
                        "measurement_unit": "",
                        "quantity": ""
                      }
                    ],
                    "additional_information": [
                      {
                        "op_type": "create",
                        "additional_info_code": "00100",
                        "additional_info_description": ""
                      }
                    ],
                    "detail_previous_document": [
                      {
                        "op_type": "create",
                        "previous_document_ref": "1224324",
                        "previous_document_class": "Y",
                        "previous_document_type": "235"
                      }
                    ],
                    "additional_procedures": [
                      {
                        "op_type": "create",
                        "additional_procedure_code": "1NV"
                      }
                    ]
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Create SPIMM
              type: http
              seq: 6
            http:
              method: POST
              url: '{{baseURL}}/internal_market_movement'
              body:
                type: json
                data: |-
                  {
                    "op_type": "create",
                    "declaration_number": "{{dec_lrn_01}}", // ENS Consignment number
                    "consignment_number": "",
                    "declaration_choice": "H1",
                    "transport_document_reference": "21321",
                    "transport_document_type": "N730",
                    "declaration_category": "IMD",
                    "goods_description": "Bread and Pastries",
                    "internal_market": "confirmed",
                    "goods_domestic_status": "D",
                    "trader_reference": "JB001",
                    "destination_country": "GB",
                    "location_of_goods_border": "GBAUBELBELBEL",
                    //"supervising_customs_office": "GBBEL004",
                    //"customs_warehouse_identifier": "U1234567",
                    "free_circulation_home_uses": "yes",
                    "representation_type": "2",
                    "mode_of_transport": "3",
                    "arrival_date_time": "{{arrival_date_time}}",
                    "ducr": "",
                    "consignor_eori": "{{consignor_eori}}",
                    "consignee_eori": "{{consignee_eori}}",
                    "importer_eori": "{{importer_eori}}",
                    "exporter_eori": "{{exporter_eori}}",
                    "container_indicator": "1",
                    "buyer_same_as_importer": "yes",
                    "align_ukims": "",
                    "header_previous_document": [
                      {
                        "op_type": "create",
                        "previous_document_class": "X",
                        "previous_document_type": "355",
                        "previous_document_ref": "80075"
                      }
                    ],
                    "detail_previous_document": [
                      {
                        "op_type": "create",
                        "previous_document_ref": "1224324",
                        "previous_document_class": "Y",
                        "previous_document_type": "355"
                      }
                    ]
                   }
              auth: inherit
            runtime:
              scripts:
                - type: after-response
                  code: |-
                    const moment = require('moment');

                    const arrival = moment()
                      .add(60, 'minutes')
                      .format('DD/MM/YYYY HH:mm:ss');

                    bru.setVar('arrival_date_time', arrival);
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Filter IMMI
              type: http
              seq: 13
            http:
              method: GET
              url: '{{baseURL}}/internal_market_movement?filter=status=Trader Input Required'
              params:
                - name: filter
                  value: status=Trader Input Required
                  type: query
              body:
                type: json
                data: ''
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Lookup SPIMM
              type: http
              seq: 7
            http:
              method: GET
              url: '{{baseURL}}/internal_market_movement?consignment_number={{dec_lrn_01}}'
              params:
                - name: consignment_number
                  value: '{{dec_lrn_01}}'
                  type: query
              body:
                type: json
                data: ''
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Read IMMI
              type: http
              seq: 5
            http:
              method: GET
              url: |-
                {{baseURL}}/internal_market_movement?reference={{glr_lrn_01}}&fields=importer_eori,header_previous_document,status,declaration_category, representative_type,error_message,
                free_circulation_home_uses,mode_of_transport,supervising_customs_office,customs_warehouse_identifier, destination_country,
                trader_reference, transport_document_reference, goods_domestic_status, holder_of_authorisation
              params:
                - name: reference
                  value: '{{glr_lrn_01}}'
                  type: query
                - name: fields
                  value: |-
                    importer_eori,header_previous_document,status,declaration_category, representative_type,error_message,
                    free_circulation_home_uses,mode_of_transport,supervising_customs_office,customs_warehouse_identifier, destination_country,
                    trader_reference, transport_document_reference, goods_domestic_status, holder_of_authorisation
                  type: query
              body:
                type: json
                data: ''
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Reclassify SPIMM H1 to H8
              type: http
              seq: 11
            http:
              method: POST
              url: '{{baseURL}}/internal_market_movement'
              body:
                type: json
                data: |-
                  {
                    "op_type": "reclassify",
                    "sup_dec_number": "{{sup_dec_number}}",
                    "reclassification_type": "h1_to_h8",
                    "internal_market_movement_complies": "yes"
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Reclassify SPIMM H8 to H1
              type: http
              seq: 12
            http:
              method: POST
              url: '{{baseURL}}/internal_market_movement'
              body:
                type: json
                data: |-
                  {
                    "op_type": "reclassify",
                    "glr_number": "{{glr_lrn_01}}",
                    "reclassification_type": "h8_to_h1"
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Submit IMMI Standalone
              type: http
              seq: 3
            http:
              method: POST
              url: '{{baseURL}}/internal_market_movement'
              body:
                type: json
                data: |-
                  {
                    "op_type": "submit",
                    "glr_number": "{{glr_lrn_01}}"
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Update  SPIMM
              type: http
              seq: 8
            http:
              method: POST
              url: '{{baseURL}}/internal_market_movement'
              body:
                type: json
                data: |-
                  {
                    "op_type": "update",
                    "declaration_number": "{{glr_lrn_01}}",
                    "consignment_number": "", //specify the consignemnt number
                    "transport_document_number": "21321",
                    "declaration_category": "IMZ",
                    "goods_description": "IMMI Goods Description",
                    "internal_market": "confirmed",
                    "goods_domestic_status": "D",
                    "trader_reference": "JB001",
                    "destination_country": "GB",
                    "supervising_customs_office": "GBBEL004",
                    "customs_warehouse_identifier": "U1234567",
                    "ducr": "",
                    "consignor_eori": "{{consignor_eori}}",
                    "consignee_eori": "{{consignee_eori}}",
                    "importer_eori": "{{importer_eori}}",
                    "exporter_eori": "{{exporter_eori}}",
                    "align_ukims": "",
                    "header_previous_document": [
                      {
                        "op_type": "create",
                        "previous_document_class": "X",
                        "previous_document_type": "355",
                        "previous_document_ref": "80085"
                      }
                    ],
                    "holder_of_authorisation": [
                      {
                        "op_type": "create",
                        "auth_role_id": "100",
                        "auth_role_type": "HA",
                        "auth_type_code": "CW1"
                      }
                    ]
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Update IMMI Standalone
              type: http
              seq: 2
            http:
              method: POST
              url: '{{baseURL}}/internal_market_movement'
              body:
                type: json
                data: |-
                  {
                    "op_type": "update",
                    "glr_number": "{{glr_lrn_01}}",//required for update request
                    "declaration_category": "IMD",
                    "representation_type": "2",
                    "free_circulation_home_uses": "Yes",
                    "mode_of_transport": "3",
                    "icr": "",
                    "maritime_inventory": "",
                    "house_airway_bill": "",
                    "arrival_date_time": "17/04/2026 18:00:00",
                    "internal_market": "confirmed",
                    "importer_eori": "{{importer_eori}}",
                    "exporter_eori": "{{exporter_eori}}",
                    "exporter_name": "",
                    "exporter_city": "",
                    "exporter_postcode": "",
                    "exporter_country": "GB",
                    "exporter_street_number": "",
                    "location_of_goods_border": "GBAUDYLBFSAGE",
                    "location_of_goods_other": "",
                    "customs_warehouse_identifier": "",
                    "transport_document_reference": "101101",
                    "trader_reference": "GLR Test",
                    "transport_document_type": "N730",
                    "location_of_goods_border":"GBAUBELBFSBEL",
                    "holder_of_authorisation": [
                      {
                        "op_type": "create",
                        "auth_role_id": "23",
                        "auth_role_type": "",
                        "auth_type_code": "TST"
                      }
                    ],
                    "header_previous_document": [
                      {
                        "op_type": "create",
                        "previous_document_class": "X",
                        "previous_document_item_identifier": "23",
                        "previous_document_ref": "4654654",
                        "previous_document_type": "740"
                      }
                    ]
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Update SPIMM Goods Items
              type: http
              seq: 10
            http:
              method: POST
              url: '{{baseURL}}/goods'
              body:
                type: json
                data: |-
                  {
                  "op_type": "update",
                  "consignment_number": "",
                  "goods_id": "{{goods_id_01}}",//required for update request
                  "commodity_code": "2301100000",
                  "procedure_code": "4000",
                  "additional_procedure_code": "1EL",
                  "country_of_origin": "GB",
                  "ni_additional_information_codes": "NIREM",
                  "goods_description": "Testing",
                  "gross_mass_kg": "100",
                  "net_mass_kg": "100",
                  "item_invoice_amount": "157.00",
                  "item_invoice_currency": "gbp",
                  "supplementary_units": "",
                  "number_of_packages": "10",
                  "document_references": [
                  {
                  "op_type": "create",
                  "document_code": "9101",
                  "document_reference": "Testing DR",
                    "document_status": "JP",
                  "document_part": "",
                  "document_reason": "TEST",
                  "date_of_validity": "",
                  "issuing_authority": "",
                  "amount": "",
                  "currency": "",
                  "measurement_unit": "",
                  "quantity": ""
                  }
                  ],
                  "additional_information": [
                  {
                  "op_type": "create",
                  "additional_info_code": "00100",
                  "additional_info_description": ""
                  }
                  ],
                  "detail_previous_document":[
                  {
                  "op_type": "create",
                  "previous_document_ref": "1224324",
                  "previous_document_class": "Y",
                  "previous_document_type": "235"
                  }
                  ],
                  "additional_procedures":[
                  {
                  "op_type": "create",
                  "additional_procedure_code": "1NV"
                  }
                    ]
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
      - info:
          name: Lookup Field Choices
          type: folder
          seq: 7
        request:
          auth: inherit
        items:
          - info:
              name: Lookup Country
              type: http
              seq: 2
            http:
              method: GET
              url: '{{baseURL}}/choice_values/country'
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Lookup Location Of Goods Border
              type: http
              seq: 4
            http:
              method: GET
              url: '{{baseURL}}/choice_values/ffd_location_of_goods'
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Lookup Movement Type
              type: http
              seq: 5
            http:
              method: GET
              url: '{{baseURL}}/choice_values/movement_type'
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Lookup Package Type
              type: http
              seq: 3
            http:
              method: GET
              url: '{{baseURL}}/choice_values/type_of_package'
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Lookup Port
              type: http
              seq: 1
            http:
              method: GET
              url: '{{baseURL}}/choice_values/port'
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
      - info:
          name: Maritime Inventory Claim
          type: folder
          seq: 8
        request:
          auth: inherit
        items:
          - info:
              name: Cancel Maritime Inventory Claim
              type: http
              seq: 4
            http:
              method: POST
              url: '{{baseURL}}/inventory_claim'
              body:
                type: json
                data: |-
                  {
                    "op_type": "cancel",
                    "icr_number": "{{icr_lrn_01}}"
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Create Maritime Inventory Claim
              type: http
              seq: 13
            http:
              method: POST
              url: '{{baseURL}}/inventory_claim'
              body:
                type: json
                data: |-
                  {
                    "op_type": "create",
                    "icr_number": "",
                    "container_number": "4546545",
                    "bill_of_lading": "Bill of lading",
                    "final_destination_location_code": "GBAULDYLDYLDY",
                    "package_count": "13",
                    "load_type": "FCL",
                    "cargo_or_consignment": "Cargo",
                    "weight": "46"
                  }
              auth: inherit
            runtime:
              actions:
                - type: set-variable
                  phase: after-response
                  selector:
                    expression: res.body.result.reference
                    method: jsonq
                  variable:
                    name: icr_lrn_01
                    scope: runtime
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Read  Maritime Inventory Claim
              type: http
              seq: 5
            http:
              method: GET
              url: |-
                {{baseURL}}/inventory_claim?reference={{icr_lrn_01}}&fields=package_count,error_message,weight,status,final_destination_location_code,load_type,cargo_or_consig
                nment,bill_of_lading,ucn,container_number,error_text,ucn,hold_reason,date_of_claim,lrn
              params:
                - name: reference
                  value: '{{icr_lrn_01}}'
                  type: query
                - name: fields
                  value: |-
                    package_count,error_message,weight,status,final_destination_location_code,load_type,cargo_or_consig
                    nment,bill_of_lading,ucn,container_number,error_text,ucn,hold_reason,date_of_claim,lrn
                  type: query
              body:
                type: json
                data: ''
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Submit Maritime Inventory Claim
              type: http
              seq: 3
            http:
              method: POST
              url: '{{baseURL}}/inventory_claim'
              body:
                type: json
                data: |-
                  {
                    "op_type": "submit",
                    "icr_number": "{{icr_lrn_01}}"
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Update Maritime Inventory Claim
              type: http
              seq: 2
            http:
              method: POST
              url: '{{baseURL}}/inventory_claim'
              body:
                type: json
                data: |-
                  {
                    "op_type": "update",
                    "icr_number": "{{icr_lrn_01}}", // required for update request
                    "container_number": "4546545",
                    "bill_of_lading": "Bill of lading",
                    "final_destination_location_code": "GBAULDYLDYLDY",
                    "package_count": "13",
                    "load_type": "MIX",
                    "cargo_or_consignment": "Cargo",
                    "weight": "46"
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
      - info:
          name: Permission Grant
          type: folder
          seq: 9
        request:
          auth: inherit
        items:
          - info:
              name: Check Permission Grant
              type: http
              seq: 1
            http:
              method: GET
              url: '{{baseURL}}/permission_grant?importer_eori={{importer_eori}}'
              params:
                - name: importer_eori
                  value: '{{importer_eori}}'
                  type: query
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
      - info:
          name: Sample Test (End To End Test)
          type: folder
          seq: 13
        request:
          auth: inherit
        items:
          - info:
              name: 'Test 01: TSS Simplified Declaration with ENS'
              type: folder
              seq: 1
            request:
              auth: inherit
              scripts:
                - type: before-request
                  code: |-
                    const moment = require('moment');

                    const arrival = moment()
                      .add(10, 'minutes')
                      .format('DD/MM/YYYY HH:mm:ss');

                    bru.setVar('arrival_date_time', arrival);
            docs:
              content: "    <Declaration xmlns:clm5ISO42173A=\"urn:un:unece:uncefact:codelist:standard:ISO:ISO3AlphaCurrencyCode:2012-08-31\" xmlns:p1=\"urn:wco:datamodel:WCO:Declaration_DS:DMS:2\" xmlns:udt=\"urn:un:unece:uncefact:data:standard:UnqualifiedDataType:6\" xsi:schemaLocation=\"urn:wco:datamodel:WCO:DEC-DMS:2 ../WCO_DEC_2_DMS.xsd \">\n        <!--\n            SCENARIO\n            To show that CDS can process an import Declaration for inherited goods, when using additional procedure C04.\n\n            An agent submits an Imports Type F declaration importing goods from ROW to GB, declaring:\n            - Procedure Code: 4000 in D.E. 1/10.\n            - Additional Procedure Code: C04 in D.E 1/11.\n            - Goods: Silver jewellery, not plated or clad with other precious metal.\n            - Commodity code 7113110000 importing goods from the country Switzerland.\n\n            The Goods Arrival Notification is submitted, the declaration becomes a Type C and CDS processes the declaration:\n\n            - No Customs Duty, Excise or VAT will be calculated using the UK Tariff.\n            - DMS will generate trader notifications.\n\n            Goods presented at Baltic Wharf, Wallasea Island (NILP).\n            -->\n        <FunctionCode>9</FunctionCode>\n        <!--DE 2/5: LRN.\n            Declarant's own reference number - this must be unique to the transaction. -->\n        <FunctionalReferenceID>78494319USHP</FunctionalReferenceID>\n        <!--DE 1/1: Declaration Type.\n            IM to represent an import declaration. -->\n        <!--DE 1/2: Additional Declaration Type.\n            F to represent a pre-lodged simplified declaration. -->\n        <TypeCode>IMF</TypeCode>\n        <!--DE 1/9: Total Number of Items.\n            Total number of goods items on the declaration. -->\n        <GoodsItemQuantity>1</GoodsItemQuantity>\n        <!--DE 6/18: Total Packages.\n            Total number of packages making up the consignment covered by the declaration.\n            As this is an Inventory Linked Import declaration, the total packages must match the consignment details held by the inventory system.\n            Note that this matches DE 6/10 because this is a single item declaration. -->\n        <TotalPackageQuantity>1</TotalPackageQuantity>\n        <!--DE 3/20: Representative Identification Number.\n            When declared, the UK requires an EORI to be provided for the representative.\n            DE 3/21: FunctionCode of 3 indicating agent acting in direct representation for the importer (holding written instruction to do so). -->\n        <Agent>\n            <FunctionCode>3</FunctionCode>\n        </Agent>\n        <!--DE 3/39: Holder of the Authorisation Identification Number.\n            An authorisation type code of SDE is required for authorisation to make a simplified declaration (see DE 2/3 where a document code of C512 has been entered). -->\n        <AuthorisationHolder>\n            <ID>GB575456994000</ID>\n            <CategoryCode>SDE</CategoryCode>\n        </AuthorisationHolder>\n        <!--DE 7/15: Nationality of the active means of transport crossing the border.\n            In this case Switzerland.\n            DE 7/4: Mode of Transport at the Border.\n            ModeCode of 1 to represent Maritime/Sea transport. -->\n        <BorderTransportMeans>\n            <RegistrationNationalityCode>CH</RegistrationNationalityCode>\n            <ModeCode>1</ModeCode>\n        </BorderTransportMeans>\n        <!--DE 3/18: Declarant Identification Number.\n            The EORI number of the agent entering the declaration.\n            The UK requires an EORI to be provided for the declarant. -->\n        <Declarant>\n            <ID>GB575456994000</ID>\n        </Declarant>\n        <!--DE 3/1: Exporter.\n            Exporter name and address is mandatory where no recognised EORI number has been entered into DE 3/2. -->\n        <Exporter>\n            <Name>Inheritance Made Easy</Name>\n            <Address>\n                <CityName>Geneva</CityName>\n                <CountryCode>CH</CountryCode>\n                <Line>8 Jewelled Avenue</Line>\n                <PostcodeID>CH1 234</PostcodeID>\n            </Address>\n        </Exporter>\n        <GoodsShipment>\n            <Consignment>\n                <!--DE 7/2: Container.\n                    Indicator to show if goods are packed in a container or not.\n                    1 indicates that goods are transported in containers.\n                    Note: unlike CHIEF this must now be completed. -->\n                <ContainerCode>1</ContainerCode>\n                <!--DE 5/23: Location of goods.\n                    Mandatory.\n                    The location code for Wallasea Island, a non-inventory linked location. -->\n                <GoodsLocation>\n                    <!--DE 5/23: Location of Goods - Identification of location.\n                        The location code for Wallasea Island, Baltic Wharf, a non-inventory linked location. -->\n                    <Name>WLALONBTW</Name>\n                    <!--DE 5/23: Location of Goods - Type of location.\n                        A to give a unique position of the location. -->\n                    <TypeCode>A</TypeCode>\n                    <Address>\n                        <!--DE 5/23: Location of Goods - Qualifier of the identification.\n                            Type of ID of the Location - U in this scenario for UN/LOCODE. -->\n                        <TypeCode>U</TypeCode>\n                        <!--DE 5/23: Location of Goods - Country.\n                            Country code of the country where the goods may be examined, GB in this scenario. -->\n                        <CountryCode>GB</CountryCode>\n                    </Address>\n                </GoodsLocation>\n                <!--DE 7/10: Container Identification Number.\n                    Example container identification number: alpha numeric to a total of 17 characters. -->\n                <TransportEquipment>\n                    <SequenceNumeric>1</SequenceNumeric>\n                    <ID>DM1234</ID>\n                </TransportEquipment>\n            </Consignment>\n            <!-- DE 5/14: Country of Dispatch/Export Code.\n                Country code of the dispatch country is CH. -->\n            <ExportCountry>\n                <ID>CH</ID>\n            </ExportCountry>\n            <GovernmentAgencyGoodsItem>\n                <!--DE 1/6: Good Item Number.\n                    Sequential number of the goods item. -->\n                <SequenceNumeric>1</SequenceNumeric>\n                <!--DE 2/3: Documents produced, certificates and authorisations, additional references.\n                    A document code C512 indicates an authorisation to use a simplified declaration. -->\n                <AdditionalDocument>\n                    <CategoryCode>C</CategoryCode>\n                    <ID>GBSDE575456994000I</ID>\n                    <TypeCode>512</TypeCode>\n                </AdditionalDocument>\n                <!--DE 2/3: Documents produced, certificates and authorisations, additional references.\n                    A document code 1421 indicates Importing inherited goods free of duty and VAT. -->\n                <AdditionalDocument>\n                    <CategoryCode>1</CategoryCode>\n                    <ID>20394857</ID>\n                    <TypeCode>421</TypeCode>\n                    <LPCOExemptionCode>GE</LPCOExemptionCode>\n                </AdditionalDocument>\n                <!--DE 2/3: Documents produced, certificates and authorisations, additional references.\n                    This field is mandatory if the codes are required.\n                    A document code of C400 indicates other certificates: Presentation of the required \"CITES\" certificate. -->\n                <AdditionalDocument>\n                    <CategoryCode>C</CategoryCode>\n                    <ID>GBICP54321</ID>\n                    <TypeCode>400</TypeCode>\n                    <LPCOExemptionCode>AC</LPCOExemptionCode>\n                </AdditionalDocument>\n                <!--DE 2/3: Documents produced, certificates and authorisations, additional references.\n                    This field is mandatory if the codes are required.\n                    C639 indicates CITES Import Commission Reg 160/2017 on the protection of species of wild fauna and flora by regulating trade therein. -->\n                <AdditionalDocument>\n                    <CategoryCode>C</CategoryCode>\n                    <ID>GBICP160/2017</ID>\n                    <TypeCode>639</TypeCode>\n                    <LPCOExemptionCode>AC</LPCOExemptionCode>\n                </AdditionalDocument>\n                <!--DE 2/3: Documents produced, certificates and authorisations, additional references.\n                    This field is mandatory if the codes are required.\n                    C679 indicates Import control on seal products for All countries.\n                    Other certificates: Attesting Document\n                    (seal product), issued by a recognised body in accordance with UK regulations [Regulation (EU) 2015/1850 as retained in UK law]. -->\n                <AdditionalDocument>\n                    <CategoryCode>C</CategoryCode>\n                    <ID>0112368</ID>\n                    <TypeCode>679</TypeCode>\n                    <LPCOExemptionCode>AE</LPCOExemptionCode>\n                </AdditionalDocument>\n                <!--DE 2/3: Documents produced, certificates and authorisations, additional references.\n                    This field is mandatory if the codes are required.\n                    9120 indicates Importation of animal pathogens Licence under the Importation of Animal pathogens Order 1980 (IAPO). -->\n                <AdditionalDocument>\n                    <CategoryCode>9</CategoryCode>\n                    <ID>GBAHC686867</ID>\n                    <TypeCode>120</TypeCode>\n                    <LPCOExemptionCode>AE</LPCOExemptionCode>\n                </AdditionalDocument>\n                <!--DE 2/3: Documents produced, certificates and authorisations, additional references.\n                    This field is mandatory if the codes are required.\n                    N271 indicates Packing list/Goods manifest/Goods Manifest where not available on an electronic inventory. -->\n                <AdditionalDocument>\n                    <CategoryCode>N</CategoryCode>\n                    <ID>1726394</ID>\n                    <TypeCode>271</TypeCode>\n                    <LPCOExemptionCode>AE</LPCOExemptionCode>\n                </AdditionalDocument>\n                <!--DE 2/3: Documents produced, certificates and authorisations, additional references.\n                    This field is mandatory if the codes are required.\n                    9028 indicates the reference number of the DEFRA Ivory Registration Number.\n                    Document status Code AC indicates Document attached for certification by customs-->\n                <AdditionalDocument>\n                    <CategoryCode>9</CategoryCode>\n                    <ID>DEFRAIV 0054041</ID>\n                    <TypeCode>028</TypeCode>\n                    <LPCOExemptionCode>AC</LPCOExemptionCode>\n                </AdditionalDocument>\n                <!--DE 2/3: Documents produced, certificates and authorisations, additional references.\n\t\t\t\t\tDocument type 9022 to indicate that goods are not subject to sanctions. -->\n                <AdditionalDocument>\n                    <CategoryCode>9</CategoryCode>\n                    <ID>Goods not subject to sanctions</ID>\n                    <Name>Goods exempt from sanctions</Name>\n                    <TypeCode>022</TypeCode>\n                </AdditionalDocument>\n                <Commodity>\n                    <!--DE 6/8: Description of Goods.\n                        Description\tspecific enough to enable classification - without repeating the CN code description in the Tariff for this scenario.\n                        Jewellery of silver, whether or not plated or clad with other precious metal. -->\n                    <Description>Silver jewellery, not plated or clad with other precious metal</Description>\n                    <!--DE 6/14: Commodity Code - Combined Nomenclature Code. -->\n                    <Classification>\n                        <ID>71131100</ID>\n                        <IdentificationTypeCode>TSP</IdentificationTypeCode>\n                    </Classification>\n                    <!--DE 6/15: Commodity Code: TARIC code. -->\n                    <Classification>\n                        <ID>00</ID>\n                        <IdentificationTypeCode>TRC</IdentificationTypeCode>\n                    </Classification>\n                    <DutyTaxFee>\n                        <!--DE 4/17: Preference.\n                            Type of 100 represents no preference being claimed. -->\n                        <DutyRegimeCode>100</DutyRegimeCode>\n                    </DutyTaxFee>\n                    <GoodsMeasure>\n                        <!--DE 6/5: Gross Mass.\n                            Weight of the goods in kilograms including packaging. -->\n                        <GrossMassMeasure unitCode=\"KGM\">5</GrossMassMeasure>\n                        <!--DE 6/1: Net Mass.\n                            Mass of the goods in kilograms without any packaging. -->\n                        <NetNetWeightMeasure unitCode=\"KGM\">0.5</NetNetWeightMeasure>\n                        <!--DE 6/2: Supplementary Units.\n                            Quantity of the goods in the unit as required by Customs for tariff, statistical or fiscal purposes. -->\n                        <TariffQuantity>500</TariffQuantity>\n                    </GoodsMeasure>\n                    <InvoiceLine>\n                        <!--DE 4/14: Item Price/ Amount.\n                            The invoice was issued with a value of 2000 and the currency was in GBP. -->\n                        <ItemChargeAmount currencyID=\"GBP\">2000</ItemChargeAmount>\n                    </InvoiceLine>\n                </Commodity>\n                <!--DE 1/10: Procedure.\n                    Requested Procedure of 40 indicating entry for free circulation and home use of goods.\n                    Previous Procedure of 00 indicating that there is no previous procedure. -->\n                <GovernmentProcedure>\n                    <CurrentCode>40</CurrentCode>\n                    <PreviousCode>00</PreviousCode>\n                </GovernmentProcedure>\n                <!--DE 1/11: Additional Procedure Code.\n                    C04 to indicate personal property acquired by inheritance. -->\n                <GovernmentProcedure>\n                    <CurrentCode>C04</CurrentCode>\n                </GovernmentProcedure>\n                <!--DE 5/15: Country of Origin.\n                    TypeCode of 1 to represent non-preferential origin.\n                    Where preference in DE 4/17 begins with '1', this must be completed.\n                    CountryCode contains the code for the country from which the goods originated, in this case Switzerland. -->\n                <Origin>\n                    <CountryCode>CH</CountryCode>\n                    <TypeCode>1</TypeCode>\n                </Origin>\n                <Packaging>\n                    <SequenceNumeric>1</SequenceNumeric>\n                    <!--DE 6/11: Shipping Marks.\n                        Marks on the packages. -->\n                    <MarksNumbersID>CDSTRADETEST1I</MarksNumbersID>\n                    <!--DE 6/10: Number of Packages.\n                        In this case 1. -->\n                    <QuantityQuantity>1</QuantityQuantity>\n                    <!--DE 6/9: Type of Packages.\n                        QP to represent Box, wooden, natural wood, ordinary. -->\n                    <TypeCode>QP</TypeCode>\n                </Packaging>\n            </GovernmentAgencyGoodsItem>\n            <!--DE 3/16: Importer Identification Number.\n                EORI number of the importer. -->\n            <Importer>\n                <ID>GB575456994000</ID>\n            </Importer>\n            <!--DE 2/1: Previous Documents.\n                Previous document to show the DUCR assigned to the consignment.\n                This is a mandatory field. -->\n            <PreviousDocument>\n                <CategoryCode>Z</CategoryCode>\n                <ID>3GB575456994000-12345</ID>\n                <TypeCode>DCR</TypeCode>\n            </PreviousDocument>\n        </GoodsShipment>\n    </Declaration>"
              type: text/markdown
            items:
              - info:
                  name: Create ENS Consignment
                  type: http
                  seq: 2
                http:
                  method: POST
                  url: '{{baseURL}}/consignments'
                  body:
                    type: json
                    data: |-
                      {
                        "op_type": "create",
                        "declaration_number": "{{ens_lrn_09}}",
                        "consignment_number": null,
                        "no_sfd_reason": null,
                        "goods_description": "Iron and Steel",
                        "trader_reference": "ABC12345",
                        "transport_document_number": "{{random_transport_document_number}}",
                        "controlled_goods": "NO",
                        "goods_domestic_status": "D",
                        "destination_country": "GB",
                        "supervising_customs_office": null,
                        "customs_warehouse_identifier": null,
                        "ducr": null,
                        "consignor_eori": null,
                        "consignor_name": "Consignor Name",
                        "consignor_street_number": "52 Mosley Street",
                        "consignor_city": "Manchester",
                        "consignor_postcode": "M1 1AJ",
                        "consignor_country": "GB",
                        "consignee_eori": null,
                        "Consignee_name": "Consignee Name",
                        "Consignee_street_number": "52 Mosley Street",
                        "Consignee_city": "Manchester",
                        "Consignee_postcode": "M1 1AJ",
                        "Consignee_country": "GB",
                        "align_ukims": "no",
                        "importer_eori": "{{importer_eori}}",
                        "importer_name": null,
                        "importer_street_number": null,
                        "importer_city": null,
                        "importer_postcode": null,
                        "importer_country": null,
                        "exporter_eori": "{{exporter_eori}}",
                        "exporter_name": null,
                        "exporter_street_number": null,
                        "exporter_city": null,
                        "exporter_postcode": null,
                        "exporter_country": null,
                        "importer_parent_organisation_eori": null,
                        "use_importer_sde": "yes",
                        "declaration_choice": "H1",
                        "generate_SD": "yes",
                        "container_indicator": "0",
                        "buyer_same_as_importer": "no",
                        "buyer_eori": null,
                        "buyer_name": "Buyer Name",
                        "buyer_street_and_number": "46 Mosley Street",
                        "buyer_city": "Manchester",
                        "buyer_postcode": "M1 1AJ",
                        "buyer_country": "GB",
                        "seller_same_as_exporter": "no",
                        "seller_eori": null,
                        "seller_name": "Seller Name",
                        "seller_street_and_number": "45 Mosley Street",
                        "seller_city": "Manchester",
                        "seller_postcode": "M1 1AJ",
                        "seller_country": "GB",
                        "header_previous_document": [],
                        "holder_of_authorisation": []
                      }
                  auth: inherit
                runtime:
                  scripts:
                    - type: before-request
                      code: |-
                        const randomNum = Math.floor(1000000000 + Math.random() * 9000000000);
                        bru.setVar("random_transport_document_number", randomNum.toString());
                  assertions:
                    - expression: res.status
                      operator: eq
                      value: '200'
                    - expression: res.body.result.reference
                      operator: matches
                      value: ^DEC[A-Za-z0-9]+$
                    - expression: res.body.result.status
                      operator: eq
                      value: created
                    - expression: res.body.result.process_message
                      operator: eq
                      value: success
                  actions:
                    - type: set-variable
                      phase: after-response
                      selector:
                        expression: res.body.result.reference
                        method: jsonq
                      variable:
                        name: dec_lrn_09
                        scope: runtime
                settings:
                  encodeUrl: true
                  timeout: 0
                  followRedirects: true
                  maxRedirects: 5
                  forwardAuthorizationHeader: true
              - info:
                  name: Create ENS Header
                  type: http
                  seq: 1
                http:
                  method: POST
                  url: '{{baseURL}}/headers'
                  body:
                    type: json
                    data: |-
                      {
                        "op_type": "create",
                        "declaration_number": null,
                        "movement_type": "3a",
                        "type_of_passive_transport": "330",
                        "identity_no_of_transport": "IMO9198941#BT70ZAR",
                        "nationality_of_transport": "GB",
                        "conveyance_ref": null,
                        "arrival_date_time": "{{arrival_date_time}}",
                        "arrival_port": "GBAUBELBELGVM",
                        "place_of_loading": "Cairnryan",
                        "place_of_acceptance_same_as_loading": "no",
                        "place_of_acceptance": "Sheffield",
                        "place_of_unloading": "Belfast",
                        "place_of_delivery_same_as_unloading": "yes",
                        "place_of_delivery": null,
                        "seal_number": null,
                        "transport_charges": "A",
                        "carrier_eori": "{{carrier_eori}}",
                        "carrier_name": "Carrier Name",
                        "carrier_street_number": "55 Abbey Road",
                        "carrier_city": "London",
                        "carrier_postcode": "NW8 0AE",
                        "carrier_country": "GB",
                        "haulier_eori": null
                      }
                  auth: inherit
                runtime:
                  scripts:
                    - type: before-request
                      code: |-
                        const moment = require('moment');

                        const arrival = moment()
                          .add(60, 'minutes')
                          .format('DD/MM/YYYY HH:mm:ss');

                        bru.setVar('arrival_date_time', arrival);
                  assertions:
                    - expression: res.status
                      operator: eq
                      value: '200'
                    - expression: res.body.result.reference
                      operator: matches
                      value: ^ENS[A-Za-z0-9]+$
                    - expression: res.body.result.status
                      operator: eq
                      value: created
                    - expression: res.body.result.process_message
                      operator: eq
                      value: success
                  actions:
                    - type: set-variable
                      phase: after-response
                      selector:
                        expression: res.body.result.reference
                        method: jsonq
                      variable:
                        name: ens_lrn_09
                        scope: runtime
                settings:
                  encodeUrl: true
                  timeout: 0
                  followRedirects: true
                  maxRedirects: 5
                  forwardAuthorizationHeader: true
              - info:
                  name: Create Goods Item
                  type: http
                  seq: 3
                http:
                  method: POST
                  url: '{{baseURL}}/goods'
                  body:
                    type: json
                    data: |-
                      {
                        "op_type": "create",
                        "consignment_number": "{{dec_lrn_09}}",
                        "goods_id": null,
                        "equipment_number": null,
                        "un_dangerous_goods_code": null,
                        "type_of_packages": "BX",
                        "number_of_packages": 10,
                        "number_of_individual_pieces": 1,
                        "package_marks": "BX12345",
                        "gross_mass_kg": 1050,
                        "net_mass_kg": 1000,
                        "goods_description": "Iron and Steel",
                        "invoice_number": null,
                        "controlled_goods": "NO",
                        "controlled_goods_type": null,
                        "commodity_code": "7202495090",
                        "country_of_origin": "FR",
                        "item_invoice_amount": "800",
                        "item_invoice_currency": "GBP",
                        "procedure_code": "4000",
                        "additional_procedure_code": "000",
                        "taric_code": null,
                        "cus_code": null,
                        "national_additional_code": null,
                        "ni_additional_information_codes": "NONE",
                        "supplementary_units": null,
                        "tax_base_unit": null,
                        "tax_base_quantity": null,
                        "tax_type": null,
                        "additional_procedures": [],
                        "document_references": [],
                        "additional_information": []
                      }
                  auth: inherit
                runtime:
                  assertions:
                    - expression: res.status
                      operator: eq
                      value: '200'
                    - expression: res.body.result.reference
                      operator: matches
                      value: ^[a-fA-F0-9]{32}$
                    - expression: res.body.result.status
                      operator: eq
                      value: created
                    - expression: res.body.result.process_message
                      operator: eq
                      value: success
                  actions:
                    - type: set-variable
                      phase: after-response
                      selector:
                        expression: res.body.result.reference
                        method: jsonq
                      variable:
                        name: goods_id_09
                        scope: runtime
                settings:
                  encodeUrl: true
                  timeout: 0
                  followRedirects: true
                  maxRedirects: 5
                  forwardAuthorizationHeader: true
              - info:
                  name: Lookup EIDR Consignment
                  type: http
                  seq: 6
                http:
                  method: GET
                  url: '{{baseURL}}/simplified_frontier_declarations?consignment_number={{dec_lrn_09}}'
                  params:
                    - name: consignment_number
                      value: '{{dec_lrn_09}}'
                      type: query
                  body:
                    type: json
                    data: ''
                  auth: inherit
                runtime:
                  variables:
                    - name: ''
                      value: ''
                  assertions:
                    - expression: res.status
                      operator: eq
                      value: '200'
                    - expression: res.body.result.sfd_number
                      operator: matches
                      value: ^DEC[A-Za-z0-9]+$
                  actions:
                    - type: set-variable
                      phase: after-response
                      selector:
                        expression: res.body.result.sfd_number
                        method: jsonq
                      variable:
                        name: eidr_lrn_09
                        scope: runtime
                settings:
                  encodeUrl: true
                  timeout: 0
                  followRedirects: true
                  maxRedirects: 5
                  forwardAuthorizationHeader: true
              - info:
                  name: Read EIDR Consignment - Authorised
                  type: http
                  seq: 7
                http:
                  method: GET
                  url: '{{baseURL}}/simplified_frontier_declarations?reference={{eidr_lrn_09}}'
                  params:
                    - name: reference
                      value: '{{eidr_lrn_09}}'
                      type: query
                  body:
                    type: json
                    data: ''
                  auth: inherit
                runtime:
                  variables:
                    - name: ''
                      value: ''
                  assertions:
                    - expression: res.status
                      operator: eq
                      value: '200'
                    - expression: res.body.result.reference
                      operator: eq
                      value: '{{eidr_lrn_09}}'
                    - expression: res.body.result.status
                      operator: eq
                      value: Authorised
                settings:
                  encodeUrl: true
                  timeout: 0
                  followRedirects: true
                  maxRedirects: 5
                  forwardAuthorizationHeader: true
              - info:
                  name: Read ENS Consignment - Authorised
                  type: http
                  seq: 5
                http:
                  method: GET
                  url: '{{baseURL}}/consignments?reference={{dec_lrn_09}}'
                  params:
                    - name: reference
                      value: '{{dec_lrn_09}}'
                      type: query
                  body:
                    type: json
                    data: ''
                  auth: inherit
                runtime:
                  variables:
                    - name: ''
                      value: ''
                  scripts:
                    - type: after-response
                      code: |-
                        // ===== Retry configuration =====
                        const maxRetries = 3;
                        const retryDelay = 500; // ms

                        // Get the retry count from runtime variable (default = 0)
                        let retryCount = bru.getVar("retryCount") || 0;

                        // Function to check empty / invalid value
                        function isEmptyOrInvalid(value) {
                          return value === undefined || value === null || value === "";
                        }

                        const movementRefNumber = res.body?.result?.movement_reference_number;

                        if (isEmptyOrInvalid(movementRefNumber)) {
                          if (retryCount < maxRetries) {
                            retryCount++;
                            bru.setVar("retryCount", retryCount);

                            console.log(`⚠️ movement_reference_number is empty/invalid. Retrying attempt ${retryCount}/${maxRetries} after ${retryDelay}ms...`);

                            // Wait 500ms before retrying
                            await new Promise((resolve) => setTimeout(resolve, retryDelay));

                            // Re-run the current request (when running in Collection Runner)
                            bru.runner.setNextRequest(req.getName());
                          } else {
                            console.log("❌ Retried 3 times but still could not get movement_reference_number. FAILED.");
                            bru.setVar("retryCount", 0); // reset for the next run
                            bru.setVar("testStatus", "failed");

                            // Throw an error to mark this request as failed
                            throw new Error("movement_reference_number is invalid after 3 retries - FAILED");
                          }
                        } else {
                          console.log("✅ movement_reference_number is valid:", movementRefNumber);
                          bru.setVar("retryCount", 0); // reset
                          bru.setVar("testStatus", "success");
                        }
                  assertions:
                    - expression: res.status
                      operator: eq
                      value: '200'
                    - expression: res.body.result.reference
                      operator: eq
                      value: '{{dec_lrn_09}}'
                    - expression: res.body.result.status
                      operator: eq
                      value: Authorised
                    - expression: res.body.result.movement_reference_number
                      operator: matches
                      value: ^26XI[A-Z0-9]{14}$
                  actions:
                    - type: set-variable
                      phase: after-response
                      selector:
                        expression: res.body.result.movement_reference_number
                        method: jsonq
                      variable:
                        name: ens_mrn
                        scope: runtime
                    - type: set-variable
                      phase: after-response
                      selector:
                        expression: res.body.result.transport_document_number
                        method: jsonq
                      variable:
                        name: ens_transport_doc
                        scope: runtime
                settings:
                  encodeUrl: true
                  timeout: 0
                  followRedirects: true
                  maxRedirects: 5
                  forwardAuthorizationHeader: true
              - info:
                  name: Submit ENS Consignment
                  type: http
                  seq: 4
                http:
                  method: POST
                  url: '{{baseURL}}/consignments'
                  body:
                    type: json
                    data: |-
                      {
                        "op_type": "submit",
                        "consignment_number": "{{dec_lrn_09}}"
                      }
                  auth: inherit
                runtime:
                  assertions:
                    - expression: res.status
                      operator: eq
                      value: '200'
                    - expression: res.body.result.reference
                      operator: eq
                      value: '{{dec_lrn_09}}'
                    - expression: res.body.result.status
                      operator: eq
                      value: submitted
                    - expression: res.body.result.process_message
                      operator: eq
                      value: success
                settings:
                  encodeUrl: true
                  timeout: 0
                  followRedirects: true
                  maxRedirects: 5
                  forwardAuthorizationHeader: true
      - info:
          name: Standard Declaration
          type: folder
          seq: 3
        request:
          auth: inherit
        items:
          - info:
              name: Create Standard Declaration
              type: http
              seq: 1
            http:
              method: POST
              url: '{{baseURL}}/full_frontier_declarations'
              body:
                type: json
                data: |-
                  {
                    "op_type": "create",
                    //"ffd_number": "",
                    "declaration_choice": "H1",
                    "declaration_category": "IMD",
                    "method_of_payment": "H",
                    "mode_of_transport": "3",
                    //"icr":"",
                    "inland_mode_of_transport": "",
                    "arrival_date_time": "{{arrival_date_time}}", //Set the date and time in future as the declaration is pre lodged.
                    "align_ukims": "yes",
                    "carrier_eori": "{{carrier_eori}}",
                    "haulier_eori": "{{haulier_eori}}",
                    "importer_eori": "{{importer_eori}}",
                    "exporter_eori": "{{exporter_eori}}",
                    //"exporter_name": "",
                    //"exporter_city": "",
                    //"exporter_country": "",
                    //"exporter_postcode": "",
                    //"exporter_street_number": "",
                    //"deferment_account_number": "123123",
                    "delivery_location_country": "GB",
                    "delivery_location_town": "Armagh",
                    "destination_country": "GB",
                    "dispatch_country": "GB",
                    //"exchange_rate": "213",
                    //"freight_charge": "21312",
                    //"freight_charge_currency": "GBP",
                    "goods_domestic_status": "D",
                    "location_of_goods_border": "GBAUBELBELBEL",
                    "location_of_goods_other": "",
                    "identity_no_of_transport": "K55 CAD",
                    "incoterm": "DAP",
                    //"insurance": "12323",
                    //"insurance_currency": "GBP",
                    "movement_type": "3",
                    "nationality_of_transport": "GB",
                    "representation_type": "3",
                    //"standard_unit_import_valuation": "no",
                    // "supervising_customs_office": "",
                    //"total_invoice": "123123",
                    //"total_invoice_currency": "GBP",
                    "total_packages": "1",
                    "trader_reference": "FFD_Test1234",
                    //"vat_adjustment": "12321",
                    //"vat_adjust_currency": "GBP",
                    "special_authorisation": "no",
                    "header_previous_document": [
                      {
                        "op_type": "create",
                        "previous_document_class": "Z",
                        "previous_document_item_identifier": "",
                        "previous_document_ref": "1234",
                        "previous_document_type": "380"
                      }
                    ],
                    "header_additions_deductions": [],
                    "holder_of_authorisation": [],
                    "guarantee_types": []
                  }
              auth: inherit
            runtime:
              scripts:
                - type: after-response
                  code: |-
                    const moment = require('moment');

                    const arrival = moment()
                      .add(60, 'minutes')
                      .format('DD/MM/YYYY HH:mm:ss');

                    bru.setVar('arrival_date_time', arrival);
              actions:
                - type: set-variable
                  phase: after-response
                  selector:
                    expression: res.body.result.reference
                    method: jsonq
                  variable:
                    name: ffd_lrn_01
                    scope: runtime
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Read Standard Declaration
              type: http
              seq: 4
            http:
              method: GET
              url: |-
                {{baseURL}}/full_frontier_declarations?reference={{ffd_lrn_01}}&fields=status,goods_
                description,customs_warehouse_identifier,error_message,error_code,movement_reference_number,transport_document_number,importer_eori,controlled_goods,ducr,holder_of_authorisation
              params:
                - name: reference
                  value: '{{ffd_lrn_01}}'
                  type: query
                - name: fields
                  value: |-
                    status,goods_
                    description,customs_warehouse_identifier,error_message,error_code,movement_reference_number,transport_document_number,importer_eori,controlled_goods,ducr,holder_of_authorisation
                  type: query
              body:
                type: json
                data: ''
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Submit Standard Declaration
              type: http
              seq: 2
            http:
              method: POST
              url: '{{baseURL}}/full_frontier_declarations'
              body:
                type: json
                data: |-
                  {
                    "op_type": "submit",
                    "ffd_number": "{{ffd_lrn_01}}"
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Update Standard Declaration
              type: http
              seq: 3
            http:
              method: POST
              url: '{{baseURL}}/full_frontier_declarations'
              body:
                type: json
                data: |-
                  {
                    "op_type": "update",
                    "ffd_number": "{{ffd_lrn_01}}", // required for update request
                    "declaration_choice": "H1",
                    "declaration_category": "IMA",
                    "method_of_payment": "H",
                    "mode_of_transport": "3",
                    "icr": "",
                    "inland_mode_of_transport": "3",
                    "arrival_date_time": "{{arrival_date_time}}",
                    "carrier_eori": "{{carrier_eori}}",
                    "haulier_eori": "{{haulier_eori}}",
                    "exporter_eori": "{{exporter_eori}}",
                    "exporter_name": "",
                    "exporter_city": "",
                    //"exporter_country": "",
                    "exporter_postcode": "",
                    "exporter_street_number": "",
                    "customs_warehouse_identifier": "AGVFR",
                    // "warehouseType":"TYUTYU",
                    "deferment_account_number": "123123",
                    "delivery_location_country": "GB",
                    "delivery_location_town": "Belfast",
                    "destination_country": "GB",
                    "dispatch_country": "GB",
                    "exchange_rate": "213",
                    "freight_charge": "21312",
                    "freight_charge_currency": "GBP",
                    "goods_domestic_status": "D",
                    "location_of_goods_border": "",
                    "location_of_goods_other": "DUBLIN",
                    "identity_no_of_transport": "123123",
                    "incoterm": "CFR",
                    "insurance": "12323",
                    "insurance_currency": "GBP",
                    "movement_type": "",
                    "nationality_of_transport": "GB",
                    "representation_type": "2",
                    "standard_unit_import_valuation": "no",
                    "supervising_customs_office": "GBAVO001",
                    "total_invoice": "123123",
                    "total_invoice_currency": "GBP",
                    "total_packages": "3",
                    "trader_reference": "FFD Test",
                    "vat_adjustment": "12321",
                    "vat_adjust_currency": "GBP",
                    "special_authorisation": "no",
                    "header_additions_deductions": [
                      {
                        "op_type": "update",
                        "addition_deduction_code": "AE",
                        "addition_deduction_currency": "GBP",
                        "addition_deduction_value": "2"
                      }
                    ],
                    "header_previous_document": [
                      {
                        "op_type": "update",
                        "previous_document_class": "X",
                        "previous_document_item_identifier": "",
                        "previous_document_ref": "1234",
                        "previous_document_type": "355"
                      }
                    ],
                    "holder_of_authorisation": [
                      {
                        "op_type": "update",
                        "auth_role_id": "",
                        "auth_role_type": "",
                        "auth_type_code": "",
                        "eori": ""
                      }
                    ]
                  }
              auth: inherit
            runtime:
              scripts:
                - type: after-response
                  code: |-
                    const moment = require('moment');

                    const arrival = moment()
                      .add(60, 'minutes')
                      .format('DD/MM/YYYY HH:mm:ss');

                    bru.setVar('arrival_date_time', arrival);
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
      - info:
          name: Simplified Declaration
          type: folder
          seq: 10
        request:
          auth: inherit
        items:
          - info:
              name: Create Simplified Declaration Header
              type: http
              seq: 1
            http:
              method: POST
              url: '{{baseURL}}/sfd_headers'
              body:
                type: json
                data: |-
                  {
                    "op_type": "create",
                    "sfd_number": "",
                    "movement_type": "3",
                    "conveyance_ref": "Test 101",
                    "identity_no_of_transport": "34353",
                    "arrival_port": "GBAUBELBELBEL",
                    "arrival_date_time": "{{arrival_date_time}}",
                    "nationality_of_transport": "GB",
                    "place_of_loading": "Birkenhead",
                    "place_of_unloading": "Belfast",
                    "seal_number": "s123756",
                    "transport_charges": "Y",
                    "carrier_eori": "{{carrier_eori}}",
                    "haulier_eori": "{{haulier_eori}}"
                  }
              auth: inherit
            runtime:
              scripts:
                - type: before-request
                  code: |-
                    const moment = require('moment');

                    const arrival = moment()
                      .add(60, 'minutes')
                      .format('DD/MM/YYYY HH:mm:ss');

                    bru.setVar('arrival_date_time', arrival);
              actions:
                - type: set-variable
                  phase: after-response
                  selector:
                    expression: res.body.result.reference
                    method: jsonq
                  variable:
                    name: sfd_header_lrn
                    scope: runtime
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: 'Create Simplified Declaration '
              type: http
              seq: 2
            http:
              method: POST
              url: '{{baseURL}}/simplified_frontier_declarations'
              body:
                type: json
                data: |-
                  {
                    "op_type": "create",
                    "sfd_parent": "{{sfd_header_lrn}}",//specify the SFD header ref
                    "goods_description": "Car parts and Seat belts",
                    "transport_document_number": "21321",
                    "controlled_goods": "no",
                    "goods_domestic_status": "D",
                    "supervising_customs_office": null,
                    "customs_warehouse_identifier": "",
                    "ducr": "",
                    "consignor_eori": "{{consignor_eori}}",
                    "consignor_name": "",
                    "consignor_street_number": "",
                    "consignor_city": "",
                    "consignor_postcode": "",
                    "consignor_country": "GB",
                    //"consignee_eori": "",
                    "consignee_name": "Fred Bloggs",
                    "consignee_street_number": "423 Falls Road",
                    "consignee_city": "Belfast",
                    "consignee_postcode": "BT1 1AA",
                    "consignee_country": "GB",
                    "importer_eori": "{{importer_eori}}",
                    "exporter_eori": "{{exporter_eori}}",
                    "exporter_name": "",
                    "exporter_street_number": "",
                    "exporter_city": "",
                    "exporter_postcode": "",
                    "exporter_country": "GB",
                    "header_previous_document": [
                      {
                        "op_type": "create",
                        "previous_document_class": "X",
                        "previous_document_type": "355",
                        "previous_document_ref": "80085"
                      }
                    ],
                    "holder_of_authorisation": [
                      {
                        "op_type": "create",
                        "auth_role_id": "{{importer_eori}}",
                        "auth_type_code": "CW1"
                      }
                    ]
                  }
              auth: inherit
            runtime:
              actions:
                - type: set-variable
                  phase: after-response
                  selector:
                    expression: res.body.result.reference
                    method: jsonq
                  variable:
                    name: dec_lrn_07
                    scope: runtime
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Filter Simplified Declaration
              type: http
              seq: 9
            http:
              method: GET
              url: '{{baseURL}}/simplified_frontier_declarations?filter=status=Trader Input Required'
              params:
                - name: filter
                  value: status=Trader Input Required
                  type: query
              body:
                type: json
                data: ''
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Lookup Simplified Declaration
              type: http
              seq: 5
            http:
              method: GET
              url: '{{baseURL}}/simplified_frontier_declarations?consignment_number=DEC#'
              params:
                - name: consignment_number
                  value: DEC#
                  type: query
                - name: sup_dec_number
                  value: SUP#
                  type: query
                  disabled: true
              body:
                type: json
                data: ''
              auth: inherit
            runtime:
              scripts:
                - type: after-response
                  code: |-
                    test("Status code is 200", function() {
                      expect(res.status).to.equal(200);
                    });

                    test ("sfd_reference is {{sfd_number }}"),function (){


                    }
              actions:
                - type: set-variable
                  phase: after-response
                  selector:
                    expression: res.body.result.sfd_number
                    method: jsonq
                  variable:
                    name: sfd_number
                    scope: runtime
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Read Simplified Declaration Header
              type: http
              seq: 6
            http:
              method: GET
              url: '{{baseURL}}/sfd_headers?reference={{sfd_header_lrn}}&fields=status,arrival_port,route,seal_number'
              params:
                - name: reference
                  value: '{{sfd_header_lrn}}'
                  type: query
                - name: fields
                  value: status,arrival_port,route,seal_number
                  type: query
              body:
                type: json
                data: ''
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Read Simplified Declaration
              type: http
              seq: 4
            http:
              method: GET
              url: |-
                {{baseURL}}/simplified_frontier_declarations?fields=freight_charge,align_ukims,vat_adjustment,standard_unit_import_valuation,total_invoice,standard_unit_import_valuationalign_ukims,addition_deduction_code,header_additions_deductions,item_add_ded_code,commodity_code,location_of_goods_border,nationality_of_transport,identity_no_of_transport,exporter_eori,haulier_eori,carrier_eori,arrival_date_time,declaration_choice,method_of_payment,special_authorisation,total_packages,insurance,delivery_location_country,delivery_location_town,movement_type,representation_type,incoterm,ni_additional_information_codes,guarantee_types,header_additions_deductions,align_ukims,decla,ration_choice,detail_previous_document,importer_eori,align_ukims,status,declaration_category, representative_type,error_message,
                free_circulation_home_uses,mode_of_transport,supervising_customs_office,customs_warehouse_identifier, destination_country,
                trader_reference, transport_document_reference, goods_domestic_status, holder_of_authorisation,header_previous_document,status,goods_
                description,error_message,transport_document_number,importer_eori,controlled_goods,ducr,holder_of_authorisation,eori_for_eidr,control_status,movement_reference_number&reference={{dec_lrn_07}}
              params:
                - name: fields
                  value: |-
                    freight_charge,align_ukims,vat_adjustment,standard_unit_import_valuation,total_invoice,standard_unit_import_valuationalign_ukims,addition_deduction_code,header_additions_deductions,item_add_ded_code,commodity_code,location_of_goods_border,nationality_of_transport,identity_no_of_transport,exporter_eori,haulier_eori,carrier_eori,arrival_date_time,declaration_choice,method_of_payment,special_authorisation,total_packages,insurance,delivery_location_country,delivery_location_town,movement_type,representation_type,incoterm,ni_additional_information_codes,guarantee_types,header_additions_deductions,align_ukims,decla,ration_choice,detail_previous_document,importer_eori,align_ukims,status,declaration_category, representative_type,error_message,
                    free_circulation_home_uses,mode_of_transport,supervising_customs_office,customs_warehouse_identifier, destination_country,
                    trader_reference, transport_document_reference, goods_domestic_status, holder_of_authorisation,header_previous_document,status,goods_
                    description,error_message,transport_document_number,importer_eori,controlled_goods,ducr,holder_of_authorisation,eori_for_eidr,control_status,movement_reference_number
                  type: query
                - name: reference
                  value: '{{dec_lrn_07}}'
                  type: query
              body:
                type: json
                data: ''
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Submit Simplified Declaration
              type: http
              seq: 3
            http:
              method: POST
              url: '{{baseURL}}/simplified_frontier_declarations'
              body:
                type: json
                data: |-
                  {
                    "op_type": "submit",
                    "sfd_number": "{{dec_lrn_07}}"
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Update Simplified Declaration Header
              type: http
              seq: 8
            http:
              method: POST
              url: '{{baseURL}}/sfd_headers?declaration_number={{sfd_header_lrn}}'
              params:
                - name: declaration_number
                  value: '{{sfd_header_lrn}}'
                  type: query
              body:
                type: json
                data: |-
                  {
                    "op_type": "update",
                    "sfd_number": "{{sfd_header_lrn}}",
                    "movement_type": "3",
                    "conveyance_ref": "Test 101",
                    "identity_no_of_transport": "34353",
                    "arrival_port": "GBAUBELBELBEL",
                    "arrival_date_time": "{{arrival_date_time}}",
                    "nationality_of_transport": "GB",
                    "place_of_loading": "Birkenhead",
                    "place_of_unloading": "Belfast",
                    "seal_number": "s123756",
                    "transport_charges": "Y",
                    "carrier_eori": "{{sfd_gb_carrier_eori}}",
                    "haulier_eori": "{{haulier_eori}}"
                  }
              auth: inherit
            runtime:
              scripts:
                - type: after-response
                  code: |-
                    const moment = require('moment');

                    const arrival = moment()
                      .add(60, 'minutes')
                      .format('DD/MM/YYYY HH:mm:ss');

                    bru.setVar('arrival_date_time', arrival);
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Update Simplified Declaration
              type: http
              seq: 7
            http:
              method: POST
              url: '{{baseURL}}/simplified_frontier_declarations'
              body:
                type: json
                data: |-
                  {
                    "op_type": "update",
                    "sfd_number": "{{dec_lrn_07}}", // required for update request
                    "sfd_parent": "",
                    "goods_description": "Car parts",
                    "transport_document_number": "21321",
                    "controlled_goods": "no",
                    "goods_domestic_status": "D",
                    "supervising_customs_office": "GBBEL003",
                    "customs_warehouse_identifier": "",
                    "ducr": "",
                    "consignor_eori": "{{consignor_eori}}",
                    "consignee_eori": "",
                    "consignee_name": "Fred Bloggs",
                    "consignee_street_number": "423 Falls Road",
                    "consignee_city": "Belfast",
                    "consignee_postcode": "BT1 1AA",
                    "consignee_country": "GB",
                    "importer_eori": "{{importer_eori}}",
                    "exporter_eori": "{{exporter_eori}}",
                    "header_previous_document": [
                      {
                        "op_type": "create",
                        "previous_document_class": "X",
                        "previous_document_type": "355",
                        "previous_document_ref": "80085"
                      }
                    ],
                    "holder_of_authorisation": [
                      {
                        "op_type": "create",
                        "auth_role_id": "GB000000000001",
                        "auth_type_code": "CW1"
                      }
                    ]
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
      - info:
          name: Supplementary Declaration
          type: folder
          seq: 11
        request:
          auth: inherit
        items:
          - info:
              name: Create Supplementary Declaration Standalone
              type: http
              seq: 8
            http:
              method: POST
              url: '{{baseURL}}/supplementary_declarations'
              body:
                type: json
                data: |-
                  {
                    "op_type": "create",
                    "authorisation_type":"ukd_sde",
                    "sup_dec_number": "",
                    "declaration_choice": "H1",
                    "controlled_goods": "no",
                    "additional_procedure": "no",
                    "supervising_customs_office": "",
                    "customs_warehouse_identifier": "",
                    "goods_domestic_status": "D",
                    "exporter_eori": "{{exporter_eori}}",
                    "exporter_name": "",
                    "exporter_street_number": "",
                    "exporter_city": "",
                    "exporter_postcode": "",
                    "exporter_country": "GB",
                    "total_packages": "12",
                    "movement_type": "3",
                    "nationality_of_transport": "GB",
                    "identity_no_of_transport": "HD60 1XL XX1254POL",
                    "freight_charge": "",
                    "freight_charge_currency": "",
                    "insurance": "",
                    "insurance_currency": "",
                    "vat_adjustment": "",
                    "vat_adjust_currency": "",
                    "total_invoice": "",
                    "total_invoice_currency": "",
                    "exchange_rate": "",
                    "postponed_vat": "no",
                    "vat_number": "",
                    "incoterm": "DAP",
                    "delivery_location_country": "GB",
                    "delivery_location_town": "Belfast",
                    "arrival_date_time":"26/04/2026 15:03:45",
                    "carrier_eori":"{{sup_dec_gb_carrier_eori}}", 
                    "header_previous_document": [
                      {
                        "op_type": "create",
                        "previous_document_class": "X",
                        "previous_document_type": "DCR",
                        "previous_document_ref": "80085"
                      }
                    ],
                    "holder_of_authorisation": [
                      {
                        "op_type": "create",
                        "auth_role_id": "{{importer_eori}}",
                        "auth_type_code": "SDE"
                      }
                    ],
                    "header_additions_deductions": [
                      {
                        "op_type": "create",
                        "addition_deduction_code": "AE",
                        "addition_deduction_value": "150"
                      }
                    ]
                  }
              auth: inherit
            runtime:
              actions:
                - type: set-variable
                  phase: after-response
                  selector:
                    expression: res.body.result.reference
                    method: jsonq
                  variable:
                    name: supp_lrn_01
                    scope: runtime
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Filter Supplementary Declaration
              type: http
              seq: 2
            http:
              method: GET
              url: '{{baseURL}}/supplementary_declarations?filter=status=Draft'
              params:
                - name: filter
                  value: status=Draft
                  type: query
              body:
                type: json
                data: ''
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Lookup Supplementary Declaration
              type: http
              seq: 7
            http:
              method: GET
              url: '{{baseURL}}/supplementary_declarations?sfd_number=DEC#'
              params:
                - name: sfd_number
                  value: DEC#
                  type: query
              body:
                type: json
                data: ''
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Read Supplementary Declaration - Goods Items
              type: http
              seq: 6
            http:
              method: GET
              url: '{{baseURL}}/supplementary_declarations?date_range=06/03/2026 - 06/03/2026'
              params:
                - name: date_range
                  value: 06/03/2026 - 06/03/2026
                  type: query
              body:
                type: json
                data: ''
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Read Supplementary Declaration
              type: http
              seq: 1
            http:
              method: GET
              url: |-
                {{baseURL}}/supplementary_declarations?reference={{supp_lrn_01}}&fields=status,goods_description,error_message,transport_document_number,importer_eori,controlled_goods,ducr,holder_of_authorisation,duty_totals,du
                ty_lines
              params:
                - name: reference
                  value: '{{supp_lrn_01}}'
                  type: query
                - name: fields
                  value: |-
                    status,goods_description,error_message,transport_document_number,importer_eori,controlled_goods,ducr,holder_of_authorisation,duty_totals,du
                    ty_lines
                  type: query
              body:
                type: json
                data: ''
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Recall Supplementary Declaration
              type: http
              seq: 5
            http:
              method: POST
              url: '{{baseURL}}/supplementary_declarations'
              body:
                type: json
                data: |-
                  {
                    "op_type": "recall",
                    "sup_dec_number": "{{supp_lrn_01}}" //if SD is in a state of “Pending Payment recallto make changes and resubmit
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Submit Supplementary Declaration
              type: http
              seq: 4
            http:
              method: POST
              url: '{{baseURL}}/supplementary_declarations'
              body:
                type: json
                data: |-
                  {
                    "op_type": "submit",
                    "sup_dec_number": "{{supp_lrn_01}}"
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
          - info:
              name: Update Supplementary Declaration Standalone
              type: http
              seq: 3
            http:
              method: POST
              url: '{{baseURL}}/supplementary_declarations'
              body:
                type: json
                data: |-
                  {
                    "op_type": "update",
                    "authorisation_type": "ukd_sde",
                    "sup_dec_number": "{{supp_lrn_01}}", // specify the SUP_DEC number
                    "declaration_choice": "H1",
                    "controlled_goods": "no",
                    "additional_procedure": "no",
                    "supervising_customs_office": "",
                    "customs_warehouse_identifier": "",
                    "goods_domestic_status": "D",
                    "exporter_eori": "{{exporter_eori}}",
                    "exporter_name": "",
                    "exporter_street_number": "",
                    "exporter_city": "",
                    "exporter_postcode": "",
                    "exporter_country": "",
                    "total_packages": "12",
                    "movement_type": "3",
                    "nationality_of_transport": "GB",
                    "identity_no_of_transport": "HD60 1XL XX1254POL",
                    "freight_charge": "",
                    "freight_charge_currency": "GBP",
                    "insurance": "",
                    "insurance_currency": "GBP",
                    "vat_adjustment": "",
                    "vat_adjust_currency": "",
                    "total_invoice": "20",
                    "total_invoice_currency": "GBP",
                    "exchange_rate": "",
                    "postponed_vat": "no",
                    "vat_number": "",
                    "incoterm": "DAP",
                    "delivery_location_country": "GB",
                    "delivery_location_town": "Belfast",
                    "arrival_date_time": "23/02/2026 15:03:45",
                    "location_of_goods_border": "GBAUMLKBELDPM",
                    "carrier_eori": "GB171809009000",
                    "header_previous_document": [
                      {
                        "op_type": "update",
                        "previous_document_class": "X",
                        "previous_document_type": "DCR",
                        "previous_document_ref": "80085"
                      }
                    ],
                    "holder_of_authorisation": [
                      {
                        "op_type": "update",
                        "auth_role_id": "{{importer_eori}}",
                        "auth_type_code": "SDE"
                      }
                    ],
                    "header_additions_deductions": [
                      {
                        "op_type": "update",
                        "addition_deduction_code": "AE",
                        "addition_deduction_value": "150",
                        "addition_deduction_currency": "GBP"
                      }
                    ]
                  }
              auth: inherit
            settings:
              encodeUrl: true
              timeout: 0
              followRedirects: true
              maxRedirects: 5
              forwardAuthorizationHeader: true
request:
  auth:
    type: oauth2
    flow: client_credentials
    accessTokenUrl: ''
    refreshTokenUrl: ''
    credentials:
      clientId: ''
      clientSecret: ''
      placement: body
    scope: ''
    tokenConfig:
      id: credentials
      placement:
        header: Bearer
    settings:
      autoFetchToken: true
      autoRefreshToken: false
  scripts:
    - type: before-request
      code: |-
        const moment = require('moment');

        const arrival = moment()
          .add(10, 'minutes')
          .format('DD/MM/YYYY HH:mm:ss');

        bru.setVar('tc_01_arrival_date_time', arrival);
docs:
  content: |
    # Guide to testing the Trader Transition API

    This document provides instructions for testing the Trader Transition API using the provided YAML file. It covers how to import the test collection, configure authentication, and handle dynamic variables in Bruno. The API collection contains all endpoints defined in the OpenAPI specification, along with sample end-to-end trader test requests.

    ## 1. Prerequisites

    Before beginning, ensure the following are available:

    1. **Bruno application**
    2. **Base URL** for the API instance
    3. **Your OAuth 2.0 credentials:**
       - **Client ID**
       - **Client Secret**
       - **Access Token URL**
       - **Scope**
              
    ## 2. Setup and Configuration

    ### 2.1. Import the API Collection in Bruno

    1. **Open** the Bruno application.  
    2. **Select** *`Import Collection`*.  
    3. **Go to** *`File > Choose file > Upload Files`* and select the **Trader Transition API Collection** `.yml` file (this file).  
    4. The **Trader API collection** will now appear in your workspace.  
    5. **Select** the collection and **set the Collection Environment** by configuring the *`baseURL`* to the provided Base URL.
     ### 2.2. Authentication with OAuth 2.0

    Authentication is required to ensure that only authorized applications can access the API. The Trader API uses **OAuth 2.0**, which involves using your credentials to obtain a temporary access token. This token is sent with each API request.

    #### Steps to Configure OAuth 2.0 in Bruno

    1. In Bruno, **select** the Trader Transition API Collection.  
    2. **Update environment variables** with your OAuth 2.0 credentials and save:  
       - `clientID`: Enter your unique Client ID  
       - `clientSecret`: Enter your unique Client Secret  
       - `scope`: `openid`  
       - `token_URL`: Enter the token URL  
    3. Navigate to **Auth**, click **Get Access Token**. You should see the message:  
       > Token fetched successfully  
    4. Bruno will now automatically manage this token. It will include the token in the header of each API request, ensuring authentication for every transaction.

    ### 2.3. Handling `arrival_date_time` Variable

    Certain API requests require specific time values for arrival and post-arrival declarations. These values are calculated automatically through **pre-request scripts** in Bruno.

    - **Pre-lodged declarations**: The *`arrival_date_time`* is set to the **current time plus 10 minutes**.  
    - **Post-Arrival Declaration (IMA)**: The *`arrival_date_time`* is set to the **current time minus 10 minutes**.
  type: text/markdown
bundled: true
extensions:
  bruno:
    ignore:
      - node_modules
      - .git
    exportedAt: '2026-09-03T21:25:25.396Z'
    exportedUsing: Bruno
