Jun 11, 2023

How to generate shipping labels with API

Learn what it takes to create an event ticket. We also show you some tricks on how to automate them with Stencil.

Sharleena AM
Technical Writer

Are you interested in building a shipping label API but struggling to find a simple solution for generating shipping labels? This tutorial will guide you through leveraging Stencil's powerful image and PDF generation API to create shipping labels with ease.

Whether you're a developer or small business owner looking to automate shipping label generation, Stencil has got you covered with its simple and user-friendly system. Say goodbye to the complicated and time-consuming process of shipping label creation.

What is Shipping Label API?

A shipping label API is an interface that allows software developers or technical users to generate shipping labels programmatically.

If you're looking for a simple solution, you can directly use Stencil to customize shipping label template using our editor and use our various integrations to generate your shipping label.

You can also build a much more complex solution to shipping label, and leave the shipping label generation to Stencil. Stencil can generate both image or PDF depending on your needs.

For example, if you run a Shopify store, you can use shipping label API to automatically generate shipping label whenever an order is received.

Steps to Build a Shipping Label API using Stencil

Step 1: Create Your Account

Go to our website and sign up for an account. You will receive a confirmation email, click on the activation link and login to Stencil with your account.

Step 2: Define Your Template

Decide on the shipping label's template or design that you want to display. Choose the font, colors, and layout for the shipping label. It should include all the necessary information needed to complete a shipment for the delivery company.

Depending on the shipping carriers, you need to abide by the format that they require. Different shipping carriers may require different dimension than our example shipping label.

What is standard shipping label format?

4 x 6 inches

The standard size of shipping labels is 4 x 6 inches (10 x 15cm). If this doesn't fit your package, then other standards are 6 x 3 inches (15 x 7cm) and 4 x 4 inches (10 x 10cm).

Step 3: Use Our APIs

Stencil provides both image and PDF formats that you can choose from, and both are accessible through our API.

Of course, you can also build your own solution by directly leveraging our image and PDF generation API. Simply call the API with the desired changes, and the label will be generated accordingly.

Below is an example of how to use the API; you can easily adapt this code based on your preferred language.

JAVASCRIPT
const data = { "template": `${TEMPLATE_ID}`, "modifications": [ { "name": "recipient_name", "src": "Amanda William" }, { "name": "recipient_address", "text": "Quay Residences\n132 Next Street" }, { "name": "tracking_number", "text": "DX-1245" }, { "name": "barcode", "text": "1234567890128" } ] } fetch('https://api.usestencil.com/v1/pdfs', { method: 'POST', body: JSON.stringify(data), headers: { 'Content-Type' : 'application/json', 'Authorization' : `Bearer ${API_KEY}` } })

Other integration example: Embeddable form

In addition to the integration with Zapier, Make, and Airtable, Stencil offers a range of versatile integrations to help you streamline and automate the label generation process. With these external tools, generating labels in bulk has never been easier.

To further simplify the process, Stencil offers an embeddable form that can be customized to suit your needs.

Below is an example of embeddable form that you can create in Stencil. Simply click "Generate Image" or "Generate PDF" to create high-quality labels in seconds. Give the demo below a try.

This is an ideal solution for those utilizing CMS platforms, such as WordPress, Drupal, Joomla, Magento, and more. Stencil's embeddable form can be easily incorporated into your CMS with minimal effort.

Step 4: Enhance the Shipping Label's Functionality

Creating shipping labels involves more than just generating and printing them; handling shipping, especially international shipments, can be daunting.

With Stencil, you can rest assured that the label generation process will be taken care of properly. No need to worry about creating a label editor - just use Stencil's template editor instead.

This frees up your time to focus on the core aspects of the shipment process, such as handling invoices and taxes, connecting with carriers, and more. Additionally, you can enhance the functionality of your shipping labels by implementing features such as barcode and tracking number integration, support for multiple languages, and tax information.

What information should I include in the shipping label QR code?

A QR code can contain a consignment note, a link to your website or other relevant information.

Why you should consider automating shipping label creation?

Automation can offer numerous benefits, particularly when it comes to repetitive and error-prone tasks such as shipping label creation.

Through the use of Stencil's programmatic and no-code image and PDF generation capabilities, you can greatly reduce the time and cost required to develop a custom shipping label solution from scratch.

Additionally, automation can help eliminate human errors such as incorrectly entering addresses, which is one of the most common mistakes made when handling shipments.

Ready to dive in?Start your free trial today.