Operations on Stripe Promotion Code objects.
A PromotionCode is the customer-facing form of a Coupon — it's the string
a customer types at checkout (e.g., "SUMMER25USER"). Multiple PromotionCodes
can share the same underlying Coupon, each with its own usage restrictions.
Identifiers
Three distinct identifiers are easy to confuse:
| Field | Example | Notes |
|---|---|---|
Coupon.id | "SUMMER25" or "8sXjvpGx" | Coupon ID. May be user-supplied on Coupon.create (D-07) or auto-generated. |
PromotionCode.id | "promo_1NxYz..." | Always Stripe-generated, prefixed promo_. |
PromotionCode.code | "SUMMER25USER" | The customer-facing string. Assignable on create via the "code" param. |
The customer types PromotionCode.code at checkout; the Stripe API accepts it
and resolves it to the PromotionCode.id, which in turn references the
underlying Coupon.
Usage
# Create a PromotionCode attached to an existing Coupon
{:ok, promo} = LatticeStripe.PromotionCode.create(client, %{
"coupon" => "SUMMER25",
"code" => "SUMMER25USER",
"active" => true,
"max_redemptions" => 100
})
# Update (deactivate)
{:ok, _} = LatticeStripe.PromotionCode.update(client, promo.id, %{"active" => "false"})Finding promotion codes
PromotionCode has no search/3 endpoint (verified absent from Stripe's OpenAPI
spec — only 7 resources have search: charges, customers, invoices, payment_intents,
prices, products, subscriptions). Discover existing promotion codes via list/2
with filters:
code— find by customer-facing code stringcoupon— all promotion codes attached to a coupon IDcustomer— promotion codes restricted to a specific customeractive— filter to only active or inactive codes
Example:
{:ok, resp} =
LatticeStripe.PromotionCode.list(client, %{
"code" => "SUMMER25USER",
"active" => "true"
})Operations not supported by the Stripe API
- search — The
/v1/promotion_codes/searchendpoint does not exist. Uselist/2with filters (see above). - delete — PromotionCodes cannot be deleted. To deactivate, call
update/4with%{"active" => "false"}.
Stripe API Reference
See the Stripe Promotion Code API.
Summary
Functions
Creates a PromotionCode. POST /v1/promotion_codes. Pass "code" for the customer-facing string (D-07).
Lists PromotionCodes with optional filters.
Retrieves a PromotionCode by ID (the promo_... ID, not the code string).
Updates a PromotionCode. POST /v1/promotion_codes/:id. Use %{"active" => "false"} to deactivate.
Types
@type t() :: %LatticeStripe.PromotionCode{ active: boolean() | nil, code: String.t() | nil, coupon: LatticeStripe.Coupon.t() | String.t() | nil, created: integer() | nil, customer: LatticeStripe.Customer.t() | String.t() | nil, expires_at: integer() | nil, extra: map(), id: String.t() | nil, livemode: boolean() | nil, max_redemptions: integer() | nil, metadata: map() | nil, object: String.t(), restrictions: map() | nil, times_redeemed: integer() | nil }
Functions
@spec create(LatticeStripe.Client.t(), map(), keyword()) :: {:ok, t()} | {:error, LatticeStripe.Error.t()}
Creates a PromotionCode. POST /v1/promotion_codes. Pass "code" for the customer-facing string (D-07).
@spec list(LatticeStripe.Client.t(), map(), keyword()) :: {:ok, LatticeStripe.Response.t()} | {:error, LatticeStripe.Error.t()}
Lists PromotionCodes with optional filters.
Filters (per D-06 discovery path): code, coupon, customer, active.
@spec retrieve(LatticeStripe.Client.t(), String.t(), keyword()) :: {:ok, t()} | {:error, LatticeStripe.Error.t()}
Retrieves a PromotionCode by ID (the promo_... ID, not the code string).
@spec stream!(LatticeStripe.Client.t(), map(), keyword()) :: Enumerable.t()
@spec update(LatticeStripe.Client.t(), String.t(), map(), keyword()) :: {:ok, t()} | {:error, LatticeStripe.Error.t()}
Updates a PromotionCode. POST /v1/promotion_codes/:id. Use %{"active" => "false"} to deactivate.