Back to Klaviyo in Excel
SheetXAI logo
Klaviyo logo
Klaviyo · Excel Guide

Generate Unique Klaviyo Coupon Codes and Write Them Into a Excel

2026-05-15
5 min read

The Scenario

Your retention team is running a win-back campaign. The plan is 500 unique 15%-off coupon codes — one per subscriber, personalized in the email. The subscriber list is in an Excel workbook: email in column A, column B is empty and waiting for the codes. Klaviyo can generate the codes. Getting them into column B of the workbook, row by row, is the technical gap.

The bad version:

  • Read Klaviyo's coupon API documentation and discover that bulk code generation is an async job — you submit a request, wait for a job to complete, then poll a second endpoint to retrieve the results.
  • Write a script to handle the two-step async pattern, run it, get back a JSON array of 500 code strings in no particular order.
  • Paste the codes into column B manually and try to match them to the right subscriber rows — discover the code order does not match the workbook row order and spend 30 minutes reconciling.

The campaign has a send date. A polling script is not in the plan.

The Easy Way: One Prompt in SheetXAI

SheetXAI is an AI agent that lives inside your Excel workbook. It handles the async Klaviyo coupon job from start to finish and writes each code back into the workbook next to the right subscriber.

Generate 500 unique coupon codes for Klaviyo coupon ID abc123 and write each code into column B of this workbook next to the corresponding subscriber email in column A

What You Get

  • A Klaviyo bulk coupon code job is submitted for 500 codes.
  • When the job completes, each code is written into column B on the row corresponding to the subscriber in column A.
  • A note at the bottom explains any shortfall if fewer codes were generated than requested.

What If the Data Is Not Quite Ready

The coupon ID is not known — only the coupon name

Create a bulk coupon code job in Klaviyo for 300 codes tied to the coupon named "WINBACK15", then populate column C of the "Reactivation" worksheet with the generated codes starting at row 2

Different subscriber segments need different coupon amounts

For rows where column C says "90-day inactive", generate 200 Klaviyo coupon codes for coupon ID abc123 and write them into column D; for rows where column C says "180-day inactive", generate 200 codes for coupon ID def456 and write them into column E

Some rows already have codes from a previous partial run

Generate Klaviyo coupon codes for coupon ID abc123 for each subscriber in column A where column B is blank, write the new code into column B, and skip any row that already has a value in column B

Full win-back prep in one shot

For every row in the "Reactivation" worksheet where column A has a valid email and column B is blank: generate a unique Klaviyo coupon code using coupon ID abc123, write the code into column B, write today's date into column C — output a count of codes generated at the bottom of column B

The campaign-ready workbook — subscribers with personalized codes — comes from one conversation.

Try It

Get the 7-day free trial of SheetXAI and open your win-back subscriber workbook, then ask it to generate and assign Klaviyo coupon codes to every row in one pass. Also see how to bulk add subscribers to a list once the campaign is sent.

Stop memorizing formulas.
Tell your spreadsheet what to do.

Join 4,000+ professionals saving hours every week with SheetXAI.

Learn more