---
title: "Create a discount"
method: POST
path: "/v1/messaging/commerce/discounts"
tags: ["Commerce"]
---

# Create a discount

`POST /v1/messaging/commerce/discounts`

## Request

- Base URL: `https://apihub.co.il`
- URL: `https://apihub.co.il/v1/messaging/commerce/discounts`
- Auth: HTTP bearer

Creates a code discount (buyers enter a code) or an automatic one (applied at checkout), as a percentage, a fixed amount or free shipping. It applies to every product unless productIds or collectionIds narrow it, and to every buyer.


**Billing:** Request; paid actions are priced in credits (see GET /v1/messaging/prices) · **Rate limit:** 60/min

## Headers

- `Idempotency-Key` string
- `X-Tag` string

## Request body

- object
  - `code` string: Required for method code.
  - `type` 'percentage' | 'fixed_amount' | 'free_shipping', required
  - `title` string, required
  - `amount` string: For type fixed_amount, a decimal in the store currency.
  - `endsAt` string, date-time, nullable
  - `method` 'code' | 'automatic', required
  - `startsAt` string, date-time: Defaults to now.
  - `accountId` string, required
  - `percentage` number: For type percentage, e.g. 15 for 15%.
  - `productIds` string[]
  - `usageLimit` integer, nullable: Code discounts only: total uses allowed.
  - `collectionIds` string[]
  - `minimumQuantity` integer, nullable
  - `minimumSubtotal` string, nullable: Minimum order subtotal, a decimal in the store currency.
  - `oncePerCustomer` boolean: Code discounts only.
  - `appliesOnEachItem` boolean: fixed_amount only: take the amount off each item instead of once per order.

## Response `200`

Completed

- object
  - `id` string: Execution id — stable across internal retries; use it with GET /v1/executions/{id}
  - `status` 'pending' | 'processing' | 'completed' | 'partial' | 'failed' | 'cancelled' | 'timeout'
  - `operation` string
  - `tag` string, nullable: Your X-Tag, if sent
  - `created_at` string, date-time
  - `completed_at` string, date-time, nullable
  - `output` object: Operation result (see each operation). While a Studio render is processing: `stage` (queued · transcribing · downloading · preparing · cleaning_voice · mixing_audio · rendering · finishing), `phase` (the engine's: download · prepare · voice · audio · encode · qa · upload, or null), `progress` (a percent, 0–100) and `progress_fraction` (0–1), `eta_seconds` (seconds left, never below 0) and `estimate_seconds`
    - `discount` object
      - `id` string
      - `type` 'percentage' | 'fixed_amount' | 'free_shipping' | 'buy_x_get_y' | 'app'
      - `codes` string[]: The first 10 codes; codeCount has the total.
      - `title` string
      - `value` union: Null for free shipping, buy-X-get-Y and app discounts.
        - object
          - `type` 'percentage'
          - `percentage` number
        - object
          - `type` 'fixed_amount'
          - `amount` object: An exact amount of money. The amount is a decimal string so cents are never lost to floating point.
            - `amount` string, required
            - `currency` string, required: ISO 4217 code. Never null: the store currency is filled in when the platform omits it.
          - `appliesOnEachItem` boolean
      - `endsAt` string, date-time, nullable
      - `method` 'code' | 'automatic'
      - `status` 'active' | 'scheduled' | 'expired'
      - `minimum` object, nullable
        - `type` 'subtotal' | 'quantity'
        - `amount` object: An exact amount of money. The amount is a decimal string so cents are never lost to floating point.
          - `amount` string, required
          - `currency` string, required: ISO 4217 code. Never null: the store currency is filled in when the platform omits it.
        - `quantity` integer
      - `summary` string
      - `platform` 'shopify'
      - `startsAt` string, date-time
      - `accountId` string
      - `appliesTo` object, nullable
        - `type` 'all' | 'products' | 'collections'
        - `productIds` string[]
        - `variantIds` string[]
        - `collectionIds` string[]
      - `codeCount` integer, nullable
      - `usageCount` integer
      - `usageLimit` integer, nullable
      - `platformData` object, nullable
      - `platformStatus` string
      - `oncePerCustomer` boolean
  - `error` string, nullable
  - `usage` object
    - `credits_charged` number, nullable
    - `credits_reserved` number
    - `estimated_credits` number
    - `cost_source` 'provider_reported' | 'calculated' | 'estimated' | 'null', nullable
    - `provider_usage` object, nullable: Normalised consumption, e.g. { VIDEO_SECOND: 22.4 }
  - `balance` object
    - `available` number
    - `reserved` number

## Other responses

- `400`: Invalid input
- `402`: Insufficient credits / project budget
- `404`: Resource not found (or not yours)
- `429`: Rate limited
- `503`: Service temporarily paused

---

[API](https://skmtc.dev/apihub/apis/apihub-one-api-for-chat-image-video-ai.md) · [All operations](https://skmtc.dev/apihub/apis/apihub-one-api-for-chat-image-video-ai/llms.txt) · [OpenAPI document](https://skmtc.dev/apihub/apis/apihub-one-api-for-chat-image-video-ai/revisions/a8caa42835ce?raw)
