Skip to content

Stripe: Create a promotion code

Stripe promotionCodes.postPromotionCodes: arguments, response, policy and SDK examples.

← Promotion codes operations · Get started

Operation stripe.postpromotioncodes

Provider route: POST /v1/promotion_codes. Alter supplies the connection’s credentials and routing.

Install @alter-ai/sdk @alter-ai/stripe with npm, or alter-sdk-stripe with pip. Supply your connected customer’s grant ID and the arguments described below.

import { App } from "@alter-ai/sdk";
import { StripeIntegration } from "@alter-ai/stripe";
async function execute(input: Parameters<StripeIntegration["promotionCodes"]["postPromotionCodes"]>[0]) {
const app = new App({ apiKey: process.env.ALTER_API_KEY! });
try {
const provider = new StripeIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! });
const call = await provider.promotionCodes.postPromotionCodes(input);
const result = await call.wait();
return result.bodyJson();
} finally {
await app.close();
}
}
import os
from alter_sdk import App
from alter_sdk_stripe import StripeIntegration
async def execute(arguments):
async with App(api_key=os.environ["ALTER_API_KEY"]) as app:
provider = StripeIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]})
call = await provider.promotion_codes.post_promotion_codes(arguments)
result = await call.wait()
return result.body_json()
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
headersobjectOptionalAdditional keys: not allowed
headers.Idempotency-KeystringOptionalMinimum length: 1
Maximum length: 255
bodyobjectRequired within parentAdditional keys: not allowed
body.activebooleanOptionalWhether the promotion code is currently active.
body.codestringOptionalThe customer-facing code. Regardless of case, this code must be unique across all active promotion codes for a specific customer. Valid characters are lower case letters (a-z), upper case letters (A-Z), digits (0-9), and dashes (-).

If left blank, we will generate one automatically.
Maximum length: 500
body.customerstringOptionalThe customer who can use this promotion code. If not set, all customers can use the promotion code.
Maximum length: 5000
body.customer_accountstringOptionalThe account representing the customer who can use this promotion code. If not set, all customers can use the promotion code.
Maximum length: 5000
body.expandarrayOptionalSpecifies which fields in the response should be expanded.
body.expand[]stringEach itemMaximum length: 5000
body.expires_atintegerOptionalThe timestamp at which this promotion code will expire. If the coupon has specified a `redeems_by`, then this value cannot be after the coupon’s `redeems_by`.
Format: unix-time
body.max_redemptionsintegerOptionalA positive integer specifying the number of times the promotion code can be redeemed. If the coupon has specified a `max_redemptions`, then this value cannot be greater than the coupon’s `max_redemptions`.
body.metadataobjectOptionalSet of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
Additional keys: see wildcard field
body.metadata.*stringAdditional keys
body.promotionobjectRequired within parentThe promotion referenced by this promotion code.
body.promotion.couponstringOptionalMaximum length: 5000
body.promotion.typestringRequired within parentOne of: coupon
body.restrictionsobjectOptionalSettings that restrict the redemption of the promotion code.
body.restrictions.currency_optionsobjectOptionalAdditional keys: see wildcard field
body.restrictions.currency_options.*objectAdditional keys
body.restrictions.currency_options.*.minimum_amountintegerOptional
body.restrictions.first_time_transactionbooleanOptional
body.restrictions.minimum_amountintegerOptional
body.restrictions.minimum_amount_currencystringOptionalFormat: currency

Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.

FieldTypePresenceDescription and constraints
$ModelRootExpand Create a promotion code — response body

Referenced models: Create a promotion code — response body

702 more schemas are linked from the tables above, on the schema pages.

Create a promotion code — response body
FieldTypePresenceDescription and constraints
$objectRootA Promotion Code represents a customer-redeemable code for an underlying promotion.
You can create multiple codes for a single promotion.

If you enable promotion codes in your [customer portal configuration](https://docs.stripe.com/customer-management/configure-portal), then customers can redeem a code themselves when updating a subscription in the portal.
Customers can also view the currently active promotion codes and coupons on each of their subscriptions in the portal.
activebooleanRequired within parentWhether the promotion code is currently active. A promotion code is only active if the coupon is also valid.
codestringRequired within parentThe customer-facing code. Regardless of case, this code must be unique across all active promotion codes for each customer. Valid characters are lower case letters (a-z), upper case letters (A-Z), digits (0-9), and dashes (-).
Maximum length: 5000
createdJSONRequired within parent
created (anyOf 1)integerAlternativeTime at which the object was created. Measured in seconds since the Unix epoch.
Format: unix-time
created (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
customerJSONOptional
customer (anyOf 1)JSONAlternativeThe customer who can use this promotion code.
customer (anyOf 1) (anyOf 1)stringAlternativeMaximum length: 5000
customer (anyOf 1) (anyOf 2)ModelAlternativeExpand Create a customer — response body
customer (anyOf 1) (anyOf 3)ModelAlternativeExpand Delete a customer — response body
customer (anyOf 2)nullAlternative
customer_accountJSONOptional
customer_account (anyOf 1)stringAlternativeThe account representing the customer who can use this promotion code.
Maximum length: 5000
customer_account (anyOf 2)nullAlternative
expires_atJSONOptional
expires_at (anyOf 1)JSONAlternative
expires_at (anyOf 1) (anyOf 1)integerAlternativeDate at which the promotion code can no longer be redeemed.
Format: unix-time
expires_at (anyOf 1) (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
expires_at (anyOf 2)nullAlternative
idstringRequired within parentUnique identifier for the object.
Maximum length: 5000
livemodebooleanRequired within parentIf the object exists in live mode, the value is `true`. If the object exists in test mode, the value is `false`.
max_redemptionsJSONOptional
max_redemptions (anyOf 1)JSONAlternative
max_redemptions (anyOf 1) (anyOf 1)integerAlternativeMaximum number of times this promotion code can be redeemed.
max_redemptions (anyOf 1) (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
max_redemptions (anyOf 2)nullAlternative
metadataJSONOptional
metadata (anyOf 1)objectAlternativeSet of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
Additional keys: see wildcard field
metadata (anyOf 1).*stringAdditional keysMaximum length: 500
metadata (anyOf 2)nullAlternative
objectstringRequired within parentString representing the object's type. Objects of the same type share the same value.
Known values: promotion_code
promotionModelRequired within parentExpand Create a promotion code — response body — promotion
restrictionsModelRequired within parentExpand Create a promotion code — response body — restrictions
times_redeemedJSONRequired within parent
times_redeemed (anyOf 1)integerAlternativeNumber of times this promotion code has been used.
times_redeemed (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$

Referenced models: Create a customer — response body, Delete a customer — response body, Create a promotion code — response body — promotion, Create a promotion code — response body — restrictions

Delete a customer — response body
FieldTypePresenceDescription and constraints
$objectRoot
deletedbooleanRequired within parentAlways true for a deleted object
Known values: True
idstringRequired within parentUnique identifier for the object.
Maximum length: 5000
objectstringRequired within parentString representing the object's type. Objects of the same type share the same value.
Known values: customer
Create a promotion code — response body — promotion
FieldTypePresenceDescription and constraints
$objectRoot
couponJSONOptional
coupon (anyOf 1)JSONAlternativeIf promotion `type` is `coupon`, the coupon for this promotion.
coupon (anyOf 1) (anyOf 1)stringAlternativeMaximum length: 5000
coupon (anyOf 1) (anyOf 2)ModelAlternativeExpand Create a coupon — response body
coupon (anyOf 2)nullAlternative
typestringRequired within parentThe type of promotion.
Known values: coupon

Referenced models: Create a coupon — response body

Create a promotion code — response body — restrictions
FieldTypePresenceDescription and constraints
$objectRoot
currency_optionsobjectOptionalPromotion code restrictions defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies).
Additional keys: see wildcard field
currency_options.*ModelAdditional keysExpand Create a promotion code — response body — restrictions currency options value
first_time_transactionbooleanRequired within parentA Boolean indicating if the Promotion Code should only be redeemed for Customers without any successful payments or invoices
minimum_amountJSONOptional
minimum_amount (anyOf 1)JSONAlternative
minimum_amount (anyOf 1) (anyOf 1)integerAlternativeMinimum amount required to redeem this Promotion Code into a Coupon (e.g., a purchase must be $100 or more to work).
minimum_amount (anyOf 1) (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
minimum_amount (anyOf 2)nullAlternative
minimum_amount_currencyJSONOptional
minimum_amount_currency (anyOf 1)stringAlternativeThree-letter [ISO code](https://stripe.com/docs/currencies) for minimum_amount
Maximum length: 5000
minimum_amount_currency (anyOf 2)nullAlternative

Referenced models: Create a promotion code — response body — restrictions currency options value

Create a Location — response body — address
FieldTypePresenceDescription and constraints
$objectRoot
cityJSONOptional
city (anyOf 1)stringAlternativeCity, district, suburb, town, or village.
Maximum length: 5000
city (anyOf 2)nullAlternative
countryJSONOptional
country (anyOf 1)stringAlternativeTwo-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
Maximum length: 5000
country (anyOf 2)nullAlternative
line1JSONOptional
line1 (anyOf 1)stringAlternativeAddress line 1, such as the street, PO Box, or company name.
Maximum length: 5000
line1 (anyOf 2)nullAlternative
line2JSONOptional
line2 (anyOf 1)stringAlternativeAddress line 2, such as the apartment, suite, unit, or building.
Maximum length: 5000
line2 (anyOf 2)nullAlternative
postal_codeJSONOptional
postal_code (anyOf 1)stringAlternativeZIP or postal code.
Maximum length: 5000
postal_code (anyOf 2)nullAlternative
stateJSONOptional
state (anyOf 1)stringAlternativeState, county, province, or region ([ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2)).
Maximum length: 5000
state (anyOf 2)nullAlternative
Create a promotion code — response body — restrictions currency options value
FieldTypePresenceDescription and constraints
$objectRoot
minimum_amountJSONRequired within parent
minimum_amount (anyOf 1)integerAlternativeMinimum amount required to redeem this Promotion Code into a Coupon (e.g., a purchase must be $100 or more to work).
minimum_amount (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
Create a Payment Method — response body — zip
FieldTypePresenceDescription and constraints
$objectRoot

SDK function policy ID: stripe.postpromotioncodes. Catalog operation: PostPromotionCodes. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.

Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.

Pinned headers: {"Stripe-Version": "2026-09-30.endive"}

Official provider source

Report an issue with this page

Necessary

Required for sign-in, security, authorization, and remembering your choices.

Always active

Analytics

Helps us understand which product and documentation features are useful.

Performance diagnostics

Uses performance tracing and privacy-masked session replay to diagnose problems.

You can change these choices at any time from Cookie settings.