LogoLogo
API DocsTemplate GalleryProduct UpdatesContact Us
  • 📬Print & Mail
    • Ready to get started?
      • Pricing details
      • Fast Track Guide
    • Integrations
      • API integrations
        • Action IQ
        • Adobe Marketo Engage
        • Blueshift
        • Braze
        • Customer.io
        • Hubspot
        • Iterable
        • Jotform
        • Klayvio
        • Listrak
        • Make
        • Optimove
        • Salesforce
        • Salesforce Marketing Cloud
        • Segment
        • Simon Data
        • Zapier
      • No-code integrations
        • Agile CRM
        • Freshsales Suite
        • HubSpot
        • Microsoft Dynamics 365
        • Pipedrive
        • Salesforce
        • Salesforce Marketing Cloud
        • Zoho
      • Creative conversion tools
        • Figma plugin
    • Reaching your audience
      • Lob Audience
        • Target Audiences
        • Lookalike Audiences
        • Purchasing Audiences
      • All about addresses
      • Campaign audience guide
      • Additional Lob NCOA functionality
    • Designing mail creatives
      • Artboard layout
      • Creative formatting
        • PDF preflight checklist
        • Exporting PDFs from InDesign
        • Rendering errors
      • Mail piece design specs
        • Postcards
        • Self-Mailers
        • Letters
        • Letter envelopes
        • Letter add-ons
        • Checks
        • Snap packs
        • Booklets
        • Custom mail
      • Maximizing engagement
        • Dynamic personalization
          • Advanced templating (Handlebars)
            • Dynamic table tutorial
        • Adding QR codes
        • Short URLs
        • Informed Delivery
    • Building a mail strategy
      • One-time campaigns or triggered sends?
      • Choosing a delivery strategy
      • Managing mail settings
        • Using metadata
        • Declaring mail use type
      • USPS Promotions Through Lob
        • Tactile, Sensory & Interactive Promotion
        • Integrated Technology Promotion
        • First Class Mail Advertising Promotion
        • Add-Ons
      • Mailing class and postage
        • Certified Mail or Registered Mail
      • International mail
    • Send mail!
      • Launch your first campaign
      • Send mail via Print & Mail API
      • Send campaigns via the Campaigns API
      • USPS Secure Destruction
    • Getting data & results
      • Tracking your mail
      • Mail analytics
      • Measuring attribution
      • Using webhooks
      • Exporting mail data
  • 🏠Address Verification
    • Ready to start AV?
      • US AV product suite
      • International AV suite
      • AV pricing
    • AV best practices
    • AV integrations & libraries
      • AV Elements
      • Shopify App: Address Cleanser
    • AV FAQs
  • 💻Developer Docs
    • API quickstart guide
    • SDKs & libraries
    • Postman & similar tools
    • Error reference
    • Upgrading API version
    • Technical use case guides
      • Mass deletion setup
      • NCOA responses
      • Override cancellation window
      • Visibility of address changes
      • Ingesting tracking events with webhooks
  • 🔑Account Management
    • Signing into Lob
    • API keys
    • Account settings
      • Account-level data logs
    • User settings
    • Billing
      • Lob Credits
      • Lob Payment Methods
      • Sales Tax FAQ
        • Applicable sales tax by state
          • ​Subscriptions and Services
          • Lob Audience
          • Delivery Location for Operational Mail
          • Customer Billing Address for Operational Mail
          • Delivery Location for Marketing Mail
          • Postage Exemption
          • Professional Services
        • Tax exemption guide
  • 📞Resources
    • Getting support
    • Security & privacy
    • Data retention
    • Sustainability
    • Private labeling Lob
    • Direct mail glossary
Powered by GitBook
On this page
  • Step 1: Create your campaign
  • Step 2: Add creative
  • Step 3: Map columns from your data file to specified fields
  • Step 4: Upload your file
  • Step 5: Execute your campaign
  • Step 6: Get failed addresses
  • Step 7: Cancel your campaign

Was this helpful?

Export as PDF
  1. Print & Mail
  2. Send mail!

Send campaigns via the Campaigns API

PreviousSend mail via Print & Mail APINextUSPS Secure Destruction

Last updated 11 months ago

Was this helpful?

This functionality is in beta. Please reach out to or your Account Manager with any feedback or feature requests.

Use our Campaigns API to send your large-scale direct mail campaign sends more programmatically.

When creating campaigns, you’ll interact with 3 main models: campaigns, creatives, and uploads.

  • The campaigns model is used to set up high-level information about your campaign

  • The creatives model is used for uploading artwork and artwork settings for your campaign

  • The uploads model is used to build your audience and configure any recipient-level details for your campaign

Follow the steps below to create your first campaign in the API.

Step 1: Create your campaign

Endpoint: POST api.lob.com/v1/campaigns Documentation:

First, create your campaign. At a minimum, your campaign needs a name and a schedule_type and a use_type if one has not been declared at the account level. It is highly recommended that a cancel_window_campaign_minutes is provided given it will allow you to cancel the campaign within the specified window if needed.

{ 
    "name": "Demo Campaign",
    "schedule_type": "immediate",
    "use_type": "marketing",
    "cancel_window_campaign_minutes": "120"
}

Step 2: Add creative

The next step is to create your creative object that will be associated with the campaign. You can only associate a single creative with a campaign. You are required to add a campaign_id, resource_type, and any requirements for your selected resource_type. This payload is subject to change depending on your form factor. See examples below.

{ 
    "campaign_id": "campaign_id",
    "resource_type": "postcard",
    "front": "{{pdf || url || template_id}}",
    "back": "{{pdf || url || template_id}}",
    "details": {
        "size": "4x6",
        "mail_type": "usps_standard_class",
    }
}
{ 
    "campaign_id": "campaign_id",
    "resource_type": "letter",
    "file": "{{pdf || url || template_id}}",
    "from": {
        "name": "Lob.com",
        "address_line1": "210 King St.",
        "address_city": "San Francisco",
        "address_state": "CA",
        "address_zip": "94107"
    }
    "details": {
        "color": true,
        "mail_type": "usps_standard_class"
    }
}

Step 3: Map columns from your data file to specified fields

If using optionalAddressColumnMapping, all fields must be specified (which means unused fields must be declared with a null value). If you're using an HTML template, double check that you have provided all keys and values for mergeVariableColumnMapping, if not all merge variables are mapped, your campaign will not be executable when it comes time to send.

{
    "campaignId": "{{campaign_id}}",
    "requiredAddressColumnMapping": {
        "name": "recipient",
        "address_line1": "address_line1",
        "address_city": "address_city",
        "address_state": "address_state",
        "address_zip": "address_zip"
    },
    "optionalAddressColumnMapping": {
        "address_line2": "address_line2",
        "company": null,
        "address_country": null
    },
    "mergeVariableColumnMapping": {
        "date": "date",
        "firstName": "firstName",
        ...
        "qr_url": "qr_url"
    },
    "metadata": {
        "columns": [
            "email"
        ]
    }
}

Step 4: Upload your file

After creating your upload object, you can now upload your file as a byte stream (binary file).

{ 
    "file": "{{file.csv}}"
}

Step 5: Execute your campaign

Finally, you can execute your campaign! To see the status of your mail pieces as they are created, use the GET api.lob.com/v1/uploads/{{upload_id}} endpoint.

{
   "is_draft": "false"
}

Step 6: Get failed addresses

First, let us know that you would like to create a failure export. Your response will include an export ID, which will be used to retrieve the export URL in the next step.

{
   "type": "failures"
}

You can then retrieve the S3 URL of the export from the GET response above. Your export will include row-level details on why each record failed.

Step 7: Cancel your campaign

Endpoint: POST api.lob.com/v1/creatives Documentation:

Note: the details section has additional optional parameters,

Endpoint: POST api.lob.com/v1/uploads Documentation:

Uploading your audience data file is the next step. Step 3 can be done prior to Step 2 as well. For more information on how to best structure your upload for Steps 3 and 4, visit our .

Endpoint: POST api.lob.com/v1/uploads/{{upload_id}}/file Documentation:

Endpoint: POST api.lob.com/v1/campaigns/{{campaign_id}}/send Documentation:

Endpoint: POST api.lob.com/v1/uploads/{{upload_id}}/exports Documentation:

Endpoint: GET api.lob.com/v1/uploads/{{upload_id}}/exports/{{export_id}} Documentation:

Endpoint: DELETE api.lob.com/v1/campaigns Documentation:

As long as your campaign cancellation window has not passed, you can your campaign using our DELETE route on the campaigns endpoint.

And that's it! If you have any questions, feel free to reach out to your Customer Success Manager, or to .

📬
support@lob.com
Create Campaign
Create Creatives
see docs for more info.
Create Upload
campaign audience guide
Upload File
Send Campaign
Create Export
Retrieve Export
Delete Campaign
support@lob.com
cancel