> ## Documentation Index
> Fetch the complete documentation index at: https://docs.automate.ax/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Automate.ax automations are TypeScript programs.
> Use Bun for installation and command examples.
> Use Automate.ax for the product name and automate.ax for the package, CLI, and domain.
> Treat documented public APIs as current; do not invent transitional or deprecated names.

# Create Loyalty Promotion

> Creates a loyalty promotion for a [loyalty program](entity:LoyaltyProgram).

`square.createLoyaltyPromotion` creates a loyalty promotion for a [loyalty program](entity:LoyaltyProgram).

## Example

```ts automations/square-create-loyalty-promotion.automation.ts theme={null}
import { automation, onDashboardRun } from "automate.ax"
import { square } from "automate.ax/square"

export default automation("Create Square Loyalty Promotion", () => {
  onDashboardRun({ title: "Create Square Loyalty Promotion" })

  square.createLoyaltyPromotion({
    programId: "program_id",
    loyaltyPromotion: {
      name: "Tuesday Happy Hour Promo",
      incentive: {
        type: "POINTS_MULTIPLIER",
        pointsMultiplierData: {
          multiplier: "3.0",
        },
      },
      availableTime: {
        timePeriods: [
          "BEGIN:VEVENT\nDTSTART:20220816T160000\nDURATION:PT2H\nRRULE:FREQ=WEEKLY;BYDAY=TU\nEND:VEVENT",
        ],
      },
      triggerLimit: {
        times: 1,
        interval: "DAY",
      },
      minimumSpendAmountMoney: {
        amount: BigInt("2000"),
        currency: "USD",
      },
      qualifyingCategoryIds: ["XTQPYLR3IIU9C44VRCB3XD12"],
    },
    idempotencyKey: "ec78c477-b1c3-4899-a209-a4e71337c996",
  })
})
```

## Inputs

Every input accepts a compatible signal. It requires `LOYALTY_WRITE`.

| Field              | Type                      | Required | Default | Description                                                                                                                                                                                           |
| ------------------ | ------------------------- | -------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `programId`        | `string`                  | Yes      | —       | The ID of the loyalty program to associate with the promotion. To get the program ID, call RetrieveLoyaltyProgram using the `main` keyword.                                                           |
| `loyaltyPromotion` | `Square.LoyaltyPromotion` | Yes      | —       | The loyalty promotion to create.                                                                                                                                                                      |
| `idempotencyKey`   | `string`                  | Yes      | —       | A unique identifier for this request, which is used to ensure idempotency. For more information, see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). |

Use the official [CreateLoyaltyPromotion reference](https://developer.squareup.com/reference/square/loyalty-api/create-loyalty-promotion) for provider field semantics and limits.

## Output

Returns the official `Square.CreateLoyaltyPromotionResponse` response as a codec-safe object. Square integer money amounts remain `bigint` values.
