Generate Shipping Label

Generate a compact PDF shipping label with sender and recipient addresses, barcode, and tracking number.

Who this is for

E-commerce platforms and fulfillment centers use this recipe to generate a shipping label on demand. Define sender and recipient addresses in a grid layout with a barcode for scanning — ready to print and attach to an outgoing package.

Request
curl -X POST https://api.iterationlayer.com/document-generation/v1/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "format": "pdf",
    "document": {
      "metadata": {
        "title": "Shipping Label - TRK-84729105",
        "author": "Greenfield Fulfillment Co."
      },
      "page": {
        "size": { "width_in_pt": 288, "height_in_pt": 432 },
        "margins": {
          "top_in_pt": 18,
          "right_in_pt": 18,
          "bottom_in_pt": 18,
          "left_in_pt": 18
        }
      },
      "styles": {
        "text": {
          "font_family": "Helvetica",
          "font_size_in_pt": 11.0,
          "line_height": 1.5,
          "color": "#333333"
        },
        "headline": {
          "font_family": "Helvetica",
          "font_size_in_pt": 24.0,
          "color": "#111111",
          "spacing_before_in_pt": 12.0,
          "spacing_after_in_pt": 6.0,
          "is_bold": true
        },
        "link": {
          "color": "#0066CC",
          "is_underlined": true
        },
        "list": {
          "text_style": {
            "font_family": "Helvetica",
            "font_size_in_pt": 11.0,
            "line_height": 1.5,
            "color": "#333333"
          },
          "marker_color": "#333333",
          "marker_gap_in_pt": 8.0
        },
        "table": {
          "header": {
            "background_color": "#333333",
            "text_color": "#FFFFFF",
            "font_size_in_pt": 11.0,
            "is_bold": true
          },
          "body": {
            "background_color": "#FFFFFF",
            "text_color": "#333333",
            "font_size_in_pt": 11.0
          },
          "border": {
            "outer": {
              "top": { "color": "#CCCCCC", "width_in_pt": 1.0 },
              "right": { "color": "#CCCCCC", "width_in_pt": 1.0 },
              "bottom": { "color": "#CCCCCC", "width_in_pt": 1.0 },
              "left": { "color": "#CCCCCC", "width_in_pt": 1.0 }
            },
            "inner": {
              "horizontal": { "color": "#EEEEEE", "width_in_pt": 0.5 },
              "vertical": { "color": "#EEEEEE", "width_in_pt": 0.5 }
            }
          }
        },
        "grid": {
          "background_color": "#FFFFFF",
          "border_color": "#CCCCCC",
          "border_width_in_pt": 0.0,
          "gap_in_pt": 12.0
        },
        "separator": {
          "color": "#CCCCCC",
          "thickness_in_pt": 1.0,
          "spacing_before_in_pt": 12.0,
          "spacing_after_in_pt": 12.0
        },
        "image": {
          "border_color": "#000000",
          "border_width_in_pt": 0.0
        }
      },
      "content": [
        { "type": "headline", "level": "h3", "text": "GREENFIELD FULFILLMENT CO." },
        { "type": "separator" },
        { "type": "grid", "columns": [
          { "column_span": 6, "blocks": [
            { "type": "paragraph", "runs": [{ "text": "FROM:", "is_bold": true }] },
            { "type": "paragraph", "markdown": "Greenfield Fulfillment Co.\n1200 Commerce Blvd, Unit 4\nAustin, TX 78701\nUnited States" }
          ]},
          { "column_span": 6, "blocks": [
            { "type": "paragraph", "runs": [{ "text": "TO:", "is_bold": true }] },
            { "type": "paragraph", "runs": [
              { "text": "Maria Vasquez", "is_bold": true },
              { "text": "\n742 Evergreen Terrace, Apt 3B\nPortland, OR 97205\nUnited States" }
            ]}
          ]}
        ]},
        { "type": "separator" },
        { "type": "grid", "columns": [
          { "column_span": 6, "blocks": [
            { "type": "paragraph", "runs": [{ "text": "Service: ", "is_bold": true }, { "text": "Priority 2-Day" }] },
            { "type": "paragraph", "runs": [{ "text": "Weight: ", "is_bold": true }, { "text": "2.4 lbs" }] }
          ]},
          { "column_span": 6, "blocks": [
            { "type": "paragraph", "runs": [{ "text": "Order: ", "is_bold": true }, { "text": "GF-2026-48291" }] },
            { "type": "paragraph", "runs": [{ "text": "Date: ", "is_bold": true }, { "text": "2026-03-06" }] }
          ]}
        ]},
        { "type": "separator" },
        {
          "type": "barcode",
          "value": "TRK84729105204839",
          "format": "code128",
          "width_in_pt": 200,
          "height_in_pt": 60,
          "fg_hex_color": "#000000",
          "bg_hex_color": "#FFFFFF"
        },
        { "type": "paragraph", "runs": [
          { "text": "Tracking: ", "is_bold": true },
          { "text": "TRK-8472-9105-2048-39" }
        ]}
      ]
    }
  }'
Response
{
  "success": true,
  "data": {
    "buffer": "JVBERi0xLjcKMSAwIG9iago8...",
    "mime_type": "application/pdf"
  }
}
Request
import { IterationLayer } from "iterationlayer";
const client = new IterationLayer({ apiKey: "YOUR_API_KEY" });

const result = await client.generateDocument({
  format: "pdf",
  document: {
    metadata: {
      title: "Shipping Label - TRK-84729105",
      author: "Greenfield Fulfillment Co.",
    },
    page: {
      size: { width_in_pt: 288, height_in_pt: 432 },
      margins: {
        top_in_pt: 18,
        right_in_pt: 18,
        bottom_in_pt: 18,
        left_in_pt: 18,
      },
    },
    styles: {
      text: {
        font_family: "Helvetica",
        font_size_in_pt: 11.0,
        line_height: 1.5,
        color: "#333333",
      },
      headline: {
        font_family: "Helvetica",
        font_size_in_pt: 24.0,
        color: "#111111",
        spacing_before_in_pt: 12.0,
        spacing_after_in_pt: 6.0,
        is_bold: true,
      },
      link: {
        color: "#0066CC",
        is_underlined: true,
      },
      list: {
        text_style: {
          font_family: "Helvetica",
          font_size_in_pt: 11.0,
          line_height: 1.5,
          color: "#333333",
        },
        marker_color: "#333333",
        marker_gap_in_pt: 8.0,
      },
      table: {
        header: {
          background_color: "#333333",
          text_color: "#FFFFFF",
          font_size_in_pt: 11.0,
          is_bold: true,
        },
        body: {
          background_color: "#FFFFFF",
          text_color: "#333333",
          font_size_in_pt: 11.0,
        },
        border: {
          outer: {
            top: { color: "#CCCCCC", width_in_pt: 1.0 },
            right: { color: "#CCCCCC", width_in_pt: 1.0 },
            bottom: { color: "#CCCCCC", width_in_pt: 1.0 },
            left: { color: "#CCCCCC", width_in_pt: 1.0 },
          },
          inner: {
            horizontal: { color: "#EEEEEE", width_in_pt: 0.5 },
            vertical: { color: "#EEEEEE", width_in_pt: 0.5 },
          },
        },
      },
      grid: {
        background_color: "#FFFFFF",
        border_color: "#CCCCCC",
        border_width_in_pt: 0.0,
        gap_in_pt: 12.0,
      },
      separator: {
        color: "#CCCCCC",
        thickness_in_pt: 1.0,
        spacing_before_in_pt: 12.0,
        spacing_after_in_pt: 12.0,
      },
      image: {
        border_color: "#000000",
        border_width_in_pt: 0.0,
      },
    },
    content: [
      { type: "headline", level: "h3", text: "GREENFIELD FULFILLMENT CO." },
      { type: "separator" },
      { type: "grid", columns: [
        { column_span: 6, blocks: [
          { type: "paragraph", runs: [{ text: "FROM:", is_bold: true }] },
          { type: "paragraph", markdown: "Greenfield Fulfillment Co.\n1200 Commerce Blvd, Unit 4\nAustin, TX 78701\nUnited States" },
        ]},
        { column_span: 6, blocks: [
          { type: "paragraph", runs: [{ text: "TO:", is_bold: true }] },
          { type: "paragraph", runs: [
            { text: "Maria Vasquez", is_bold: true },
            { text: "\n742 Evergreen Terrace, Apt 3B\nPortland, OR 97205\nUnited States" },
          ]},
        ]},
      ]},
      { type: "separator" },
      { type: "grid", columns: [
        { column_span: 6, blocks: [
          { type: "paragraph", runs: [{ text: "Service: ", is_bold: true }, { text: "Priority 2-Day" }] },
          { type: "paragraph", runs: [{ text: "Weight: ", is_bold: true }, { text: "2.4 lbs" }] },
        ]},
        { column_span: 6, blocks: [
          { type: "paragraph", runs: [{ text: "Order: ", is_bold: true }, { text: "GF-2026-48291" }] },
          { type: "paragraph", runs: [{ text: "Date: ", is_bold: true }, { text: "2026-03-06" }] },
        ]},
      ]},
      { type: "separator" },
      {
        type: "barcode",
        value: "TRK84729105204839",
        format: "code128",
        width_in_pt: 200,
        height_in_pt: 60,
        fg_hex_color: "#000000",
        bg_hex_color: "#FFFFFF",
      },
      { type: "paragraph", runs: [
        { text: "Tracking: ", is_bold: true },
        { text: "TRK-8472-9105-2048-39" },
      ]},
    ],
  },
});

console.log(result);
Response
{
  "success": true,
  "data": {
    "buffer": "JVBERi0xLjcKMSAwIG9iago8...",
    "mime_type": "application/pdf"
  }
}
Request
from iterationlayer import IterationLayer
client = IterationLayer(api_key="YOUR_API_KEY")

result = client.generate_document(
    format="pdf",
    document={
        "metadata": {
            "title": "Shipping Label - TRK-84729105",
            "author": "Greenfield Fulfillment Co.",
        },
        "page": {
            "size": {"width_in_pt": 288, "height_in_pt": 432},
            "margins": {
                "top_in_pt": 18,
                "right_in_pt": 18,
                "bottom_in_pt": 18,
                "left_in_pt": 18,
            },
        },
        "styles": {
            "text": {
                "font_family": "Helvetica",
                "font_size_in_pt": 11.0,
                "line_height": 1.5,
                "color": "#333333",
            },
            "headline": {
                "font_family": "Helvetica",
                "font_size_in_pt": 24.0,
                "color": "#111111",
                "spacing_before_in_pt": 12.0,
                "spacing_after_in_pt": 6.0,
                "is_bold": True,
            },
            "link": {
                "color": "#0066CC",
                "is_underlined": True,
            },
            "list": {
                "text_style": {
                    "font_family": "Helvetica",
                    "font_size_in_pt": 11.0,
                    "line_height": 1.5,
                    "color": "#333333",
                },
                "marker_color": "#333333",
                "marker_gap_in_pt": 8.0,
            },
            "table": {
                "header": {
                    "background_color": "#333333",
                    "text_color": "#FFFFFF",
                    "font_size_in_pt": 11.0,
                    "is_bold": True,
                },
                "body": {
                    "background_color": "#FFFFFF",
                    "text_color": "#333333",
                    "font_size_in_pt": 11.0,
                },
                "border": {
                    "outer": {
                        "top": {"color": "#CCCCCC", "width_in_pt": 1.0},
                        "right": {"color": "#CCCCCC", "width_in_pt": 1.0},
                        "bottom": {"color": "#CCCCCC", "width_in_pt": 1.0},
                        "left": {"color": "#CCCCCC", "width_in_pt": 1.0},
                    },
                    "inner": {
                        "horizontal": {"color": "#EEEEEE", "width_in_pt": 0.5},
                        "vertical": {"color": "#EEEEEE", "width_in_pt": 0.5},
                    },
                },
            },
            "grid": {
                "background_color": "#FFFFFF",
                "border_color": "#CCCCCC",
                "border_width_in_pt": 0.0,
                "gap_in_pt": 12.0,
            },
            "separator": {
                "color": "#CCCCCC",
                "thickness_in_pt": 1.0,
                "spacing_before_in_pt": 12.0,
                "spacing_after_in_pt": 12.0,
            },
            "image": {
                "border_color": "#000000",
                "border_width_in_pt": 0.0,
            },
        },
        "content": [
            {"type": "headline", "level": "h3", "text": "GREENFIELD FULFILLMENT CO."},
            {"type": "separator"},
            {"type": "grid", "columns": [
                {"column_span": 6, "blocks": [
                    {"type": "paragraph", "runs": [{"text": "FROM:", "is_bold": True}]},
                    {"type": "paragraph", "markdown": "Greenfield Fulfillment Co.\n1200 Commerce Blvd, Unit 4\nAustin, TX 78701\nUnited States"},
                ]},
                {"column_span": 6, "blocks": [
                    {"type": "paragraph", "runs": [{"text": "TO:", "is_bold": True}]},
                    {"type": "paragraph", "runs": [
                        {"text": "Maria Vasquez", "is_bold": True},
                        {"text": "\n742 Evergreen Terrace, Apt 3B\nPortland, OR 97205\nUnited States"},
                    ]},
                ]},
            ]},
            {"type": "separator"},
            {"type": "grid", "columns": [
                {"column_span": 6, "blocks": [
                    {"type": "paragraph", "runs": [{"text": "Service: ", "is_bold": True}, {"text": "Priority 2-Day"}]},
                    {"type": "paragraph", "runs": [{"text": "Weight: ", "is_bold": True}, {"text": "2.4 lbs"}]},
                ]},
                {"column_span": 6, "blocks": [
                    {"type": "paragraph", "runs": [{"text": "Order: ", "is_bold": True}, {"text": "GF-2026-48291"}]},
                    {"type": "paragraph", "runs": [{"text": "Date: ", "is_bold": True}, {"text": "2026-03-06"}]},
                ]},
            ]},
            {"type": "separator"},
            {
                "type": "barcode",
                "value": "TRK84729105204839",
                "format": "code128",
                "width_in_pt": 200,
                "height_in_pt": 60,
                "fg_hex_color": "#000000",
                "bg_hex_color": "#FFFFFF",
            },
            {"type": "paragraph", "runs": [
                {"text": "Tracking: ", "is_bold": True},
                {"text": "TRK-8472-9105-2048-39"},
            ]},
        ],
    },
)

print(result)
Response
{
  "success": true,
  "data": {
    "buffer": "JVBERi0xLjcKMSAwIG9iago8...",
    "mime_type": "application/pdf"
  }
}
Request
package main

import il "github.com/iterationlayer/sdk-go"

client := il.NewClient("YOUR_API_KEY")

result, err := client.GenerateDocument(il.GenerateDocumentRequest{
    Format: "pdf",
    Document: il.DocumentDefinition{
        Metadata: il.DocumentMetadata{
            Title:  "Shipping Label - TRK-84729105",
            Author: "Greenfield Fulfillment Co.",
        },
        Page: il.DocumentPage{
            Size:    il.DocPageSize{WidthInPt: 288, HeightInPt: 432},
            Margins: il.DocMargins{TopInPt: 18, RightInPt: 18, BottomInPt: 18, LeftInPt: 18},
        },
        Content: []il.ContentBlock{
            il.NewHeadlineBlock("h3", "GREENFIELD FULFILLMENT CO."),
            il.NewSeparatorBlock(),
            il.NewGridBlock([]il.GridColumn{
                {ColumnSpan: 6, Blocks: []il.ContentBlock{
                    il.NewParagraphBlock(),
                }},
                {ColumnSpan: 6, Blocks: []il.ContentBlock{
                    il.NewParagraphBlock(),
                }},
            }),
            il.NewSeparatorBlock(),
            il.NewBarcodeBlock(0, "TRK84729105204839", "code128", "#000000", "#FFFFFF",
                il.Position{},
                il.Dimensions{WidthInPx: 200, HeightInPx: 60}),
        },
    },
})
Response
{
  "success": true,
  "data": {
    "buffer": "JVBERi0xLjcKMSAwIG9iago8...",
    "mime_type": "application/pdf"
  }
}

Related Recipes

Start building in minutes

Free trial credits included. No credit card required.