Show / Hide Table of Contents

    Getting Customs Docs and Invoices

    • 02/06/2020
    • ~3 minutes to read
    • 02/06/2020
    • ~3 minutes to read
    • andy.walton@sorted.com
    • michael.rose@sorted.com
    • customs
    • docs
    • documents
    • pro
    • api
    • consignments

    This page explains the various way in which SortedPRO can return return customs documents and commercial invoices.


    Customs Docs in PRO

    When shipping internationally, SortedPRO will automatically determine if customs documentation is required for a consignment. SortedPRO can automatically generate CN22, CN23, or Commercial Invoice documents in PDF format and will determine which document is appropriate for any allocated consignment. The Customs Docs APIs enable you to retrieve the pre-generated documents.

    Note

    Following the UK's departure from the EU, certain additional consignment properties must be passed in order for PRO to generate customs documentation for UK-originating international consignments. In addition, certain carriers have their own data requirements that UK-originating international consignments must meet in order to be considered for allocation to that carrier.

    For an explanation of Brexit-related data requirements, see the Brexit Data Guide page.

    The Customs Docs API has three endpoints:

    • Get Commercial Invoice - returns a consignment's commercial invoice.
    • Get Customs Document - returns a CN22 or CN23 document for a particular package.
    • Get Customs Documents - returns all customs documents for a particular consignment.
    Caution

    You can only retrieve documents for consignments that have been allocated to a carrier. If you attempt to return labels for an unallocated consignment, PRO returns an error.

    Getting Commercial Invoices

    To call Get Commercial Invoice, send a GET request to https://api.electioapp.com/consignments/docs/commercialinvoice/{consignmentReference}. PRO returns the commercial invoice for the relevant consignment as a base-64 encoded byte array.

    Note

    For full reference information on the Get Commercial Invoice endpoint, see the API reference.

    Getting an Individual Customs Document

    To call Get Customs Document, send a GET request to https://api.electioapp.com/consignments/docs/{customsDocumentType}/{consignmentReference}/{packageReference}. The {customsDocumentType} can return either CN22 or CN23 documents.

    PRO returns the relevant document as a base-64 encoded byte array.

    Note

    For full reference information on the Get Customs Document endpoint, see the API reference.

    Getting All Customs Documents for a Consignment

    To call Get Customs Documents, send a GET request to https://api.electioapp.com/consignments/docs/{consignmentReference}.

    PRO returns an object containing two properties: a CommercialInvoiceDocuments property containing the consignment's commercial invoice and either a CN22Documents property containing all CN22 documents for the consignment or a CN23Documents property containing all CN23 documents for the consignment.

    All documents are represented as key / value pairs, with the key as the filename for the document and the value containing the document data.

    Note

    For full reference information on the Get Customs Documents endpoint, see the API reference.

    Get Customs Documents Example

    This example shows a Get Customs Documents response for a single-package consignment. PRO has returned a commercial invoice for the consignment and a CN22 document for the package.

    • Get Customs Documents Response
    {
      "CommercialInvoiceDocuments": [
        {
          "Key": "INV_Example",
          "Value": "(document data)"
        }
      ],
      "CN22Documents": [
        {
          "Key": "CN22_Example",
          "Value": "(document data)"
        }
      ]
    }
    
    Note

    Once you have downloaded the file data, you will need to decode the file's Base64 in order to view the document itself. If you are unsure how to do so, see the MDN docs for more information.

    Next Steps

    • Learn how to get and print delivery labels at the Getting Labels page.
    • Learn how to add consignments to a carrier manifest at the Manifesting Consignments page.
    • Learn how to track consignments at the Tracking Consignments page.
    Note

    All of the URLs and examples given in this documentation relate to PRO's live production environment. To call APIs in the sandbox environment, substitute the api.electioapp.com portion of the API's base URL with apisandbox.electioapp.com. Don't forget to use your sandbox API key (as opposed to your production API key) when making the call.

    For more information on PRO's sandbox, see Using the Sandbox Environment.

    Back to top Copyright © Sorted Group 2021. Generated by DocFX