# Create discount.

Create discount.

Endpoint: POST /discounts
Version: 1.0.0
Security: Token

## Request fields (application/json):

  - `order_id` (string, required)
    ID of the order apply this coupon to. UUID Version 4.
    Example: "00000000-0000-4000-8000-000000000000"

  - `coupon_id` (string)
    ID of the coupon to apply. UUID Version 4.
    Example: "00000000-0000-4000-8000-000000000000"

  - `coupon_data` (object)
    Data to construct an ad hoc coupon inline to apply to this order. If you create a coupon upfront, pass the coupon_id parameter. Otherwise, this coupon_data will be used to scaffold a new ad hoc Coupon.

  - `coupon_data.name` (string)
    Name of the coupon displayed to customers on orders.
    Example: "VIP Customer Discount"

  - `coupon_data.percent_off` (number)
    A decimal value representing the percent that will be taken off the subtotal of an order this coupon is applied to. For example, 0.500 would represent an applied discount of 50%, meaning an order with a subtotal of $100 would result in a balance of $50. Required if amount_off is null.
    Example: 0.075

  - `coupon_data.amount_off` (integer)
    Amount that will be taken off the subtotal of any orders this coupon is applied to. Amount represented in the smallest currency unit (that is, 100 cents for $1.00). Required if percent_off is null.
    Example: 2500

## Response 201 fields (application/json):

  - `status` (string, required)
    What was the state of the request?
    Example: "success"

  - `data` (object)
    A discount represents the application of a coupon to an order or order item. It includes the calculated amount to be discounted based on the coupon configuration.

  - `data.object` (string)
    A canonical value representing a resource.
    Enum: "DISCOUNT"

  - `data.id` (string, required)
    ID of the entity. UUID Version 4.
    Example: "00000000-0000-4000-8000-000000000000"

  - `data.total_discount_amount` (integer)
    The total discount amount.
    Example: 1000

  - `data.coupon` (object)
    A coupon contains information about a percent-off or amount-off discount you might want to apply to an order.

  - `data.coupon.id` (string, required)
    ID of the entity. UUID Version 4.
    Example: "00000000-0000-4000-8000-000000000000"

  - `data.coupon.name` (string)
    Name of the coupon displayed to customers on orders.
    Example: "VIP Customer Discount"

  - `data.coupon.is_active` (boolean)
    Indicates if the coupon is currently active.
    Example: true

  - `data.coupon.is_percent_off` (boolean)
    Indicates if the coupon is a percent off coupon.
    Example: true

  - `data.coupon.percent_off` (number)
    A decimal value representing the percent that will be taken off the subtotal of an order this coupon is applied to. For example, 0.500 would represent an applied discount of 50%, meaning an order with a subtotal of $100 would result in a balance of $50.
    Example: 0.075

  - `data.coupon.amount_off` (integer)
    Amount that will be taken off the subtotal of any orders this coupon is applied to. Amount represented in the smallest currency unit (that is, 100 cents for $1.00).
    Example: 2500

  - `data.coupon.amount_off_formatted` (string)
    The amount off formatted as a string.
    Example: "$25.00"

  - `data.coupon.promotion_codes` (array)

  - `data.coupon.promotion_codes.id` (string, required)
    ID of the entity. UUID Version 4.
    Example: "00000000-0000-4000-8000-000000000000"

  - `data.coupon.promotion_codes.code` (string, required)
    The customer-facing code. This code must be unique across all active promotion codes.
    Example: "SPRING_SALE"

  - `data.coupon.promotion_codes.times_redeemed` (integer)
    The number of times the coupon has been redeemed.
    Example: 10

  - `data.coupon.promotion_codes.start_at` (string,null)
    The date and time (ISO 8601 format) when the promotion code will be active.
    Example: "2021-06-30T20:30:00Z"

  - `data.coupon.promotion_codes.end_at` (string,null)
    The date and time (ISO 8601 format) when the promotion code will no longer be active.
    Example: "2021-06-30T20:30:00Z"

  - `data.coupon.promotion_codes.max_redemptions` (integer,null)
    The maximum number of times the promotion code can be redeemed.
    Example: 10

  - `data.coupon.promotion_codes.max_redemptions_per_customer` (integer,null)
    The maximum number of times the promotion code can be redeemed per customer.
    Example: 10

  - `data.coupon.promotion_codes.first_time_only` (boolean,null)
    Indicates if the promotion code can only be redeemed once per customer.
    Example: true

  - `data.coupon.promotion_codes.minimum_amount` (integer,null)
    The minimum amount that must be in the cart before the promotion code can be applied.
    Example: 1000

  - `data.coupon.promotion_codes.is_portal_mobile_app_only` (boolean,null)
    Indicates if the promotion code can only be redeemed on the portal mobile app.
    Example: true

  - `data.coupon.discountables` (array)

  - `data.coupon.discountables.object` (string)
    String representing the object’s type. Objects of the same type share the same schema.
    Example: "DISCOUNTABLE"

  - `data.coupon.discountables.id` (string, required)
    ID of the entity. UUID Version 4.
    Example: "00000000-0000-4000-8000-000000000000"

  - `data.coupon.discountables.discountable` (object)
    A discountable item.

  - `data.coupon.discountables.discountable.object` (string)
    A canonical value representing a resource.
    Example: "PRODUCT"

  - `data.coupon.discountables.discountable.id` (string, required)
    ID of the entity. UUID Version 4.
    Example: "00000000-0000-4000-8000-000000000000"

  - `data.coupon.discountables.discountable.title` (string)
    The title of the item.
    Example: "House photos"

  - `data.coupon.discountables.discountable.description` (string)
    The description of the item.
    Example: "Capture photos of a house for sale."

  - `data.coupon.discountables.discountable.active` (boolean)
    The active status of an item.
    Example: true

  - `data.coupon.discountables.discountable.type` (string)
    The type of item.
    Example: "MAIN"

  - `data.coupon.discountables.discountable.is_twilight` (boolean)
    Whether the item is available during twilight hours.
    Example: true

  - `data.coupon.discountables.discountable.image_url` (string,null)
    A URL for an example property image.
    Example: "https://picsum.photos/400/200"

  - `data.coupon.discountables.discountable.is_serviceable` (boolean)
    Whether the item is serviceable.
    Example: true

  - `data.coupon.discountables.discountable.requires_separate_booking` (boolean)
    Whether the item requires a separate booking.
    Example: true

  - `data.coupon.discountables.discountable.always_display_addons` (boolean)
    Whether to always display addons for the item.
    Example: true

  - `data.coupon.discountables.discountable.variant_filter_type` (string,null)
    The type of variant filter.
    Example: "ALL"

  - `data.coupon.discountables.discountable.avalara_tax_code` (string,null)
    The Avalara tax code for the item.
    Example: "12345"

  - `data.coupon.discountables.discountable.limit_quantity_amount` (integer,null)
    The limit quantity amount for the item.
    Example: 10

  - `data.coupon.discountables.discountable.limit_quantity` (boolean)
    Whether the item has a limit quantity.
    Example: true

  - `data.coupon.discountables.discountable.is_filterable` (boolean)
    Whether the item is filterable.
    Example: true

  - `data.coupon.discountables.discountable.is_esoft_adjustment` (boolean)
    Whether the item is an eSoft adjustment.
    Example: true

  - `data.coupon.discountables.discountable.variants` (array)

  - `data.coupon.discountables.discountable.variants.object` (string)
    A canonical value representing a resource.
    Enum: "PRODUCT_VARIANT"

  - `data.coupon.discountables.discountable.variants.id` (string, required)
    ID of the entity. UUID Version 4.
    Example: "00000000-0000-4000-8000-000000000000"

  - `data.coupon.discountables.discountable.variants.title` (string, required)
    The title of the product variant.
    Example: "House photos"

  - `data.coupon.discountables.discountable.variants.price` (integer)
    A positive integer in the smallest currency unit (that is, 100 cents for $1.00) representing the price of the product variant.
    Example: 10000

  - `data.coupon.discountables.discountable.variants.price_amount` (integer)
    A positive integer in the smallest currency unit (that is, 100 cents for $1.00) representing the price of the product variant.
    Example: 10000

  - `data.coupon.discountables.discountable.variants.base_price_amount` (integer)
    A positive integer in the smallest currency unit (that is, 100 cents for $1.00) representing the price of the product variant.
    Example: 10000

  - `data.coupon.discountables.discountable.variants.base_is_hidden` (boolean)
    Indicates if the base price of the product variant is hidden.
    Example: true

  - `data.coupon.discountables.discountable.variants.display_original_price` (boolean)
    Indicates if the original price of the product variant should be displayed.
    Example: true

  - `data.coupon.discountables.discountable.variants.duration` (integer)
    The duration of the product item, in minutes.
    Example: 60

  - `data.coupon.discountables.discountable.categories` (array)

  - `data.coupon.discountables.discountable.categories.object` (string)
    A canonical value representing a resource.
    Enum: "PRODUCT_CATEGORY"

  - `data.coupon.discountables.discountable.categories.id` (string, required)
    ID of the entity. UUID Version 4.
    Example: "00000000-0000-4000-8000-000000000000"

  - `data.coupon.discountables.discountable.categories.title` (string, required)
    The title of the product category.
    Example: "Photography"

  - `data.coupon.discountables.discountable.categories.name` (string)
    The name of the product category.
    Example: "Photography"

  - `data.coupon.discountables.discountable.categories.slug` (string)
    The slug of the product category.
    Example: "photography"

  - `data.coupon.discountables.discountable.categories.color` (string)
    The color of the product category.
    Example: "#000000"

  - `data.coupon.discountables.discountable.categories.type` (string)
    The type of the product category.
    Example: "product"

  - `data.coupon.discountables.discountable.quickbooks_item_id` (string,null)
    The Quickbooks item ID for the item.
    Example: "12345"

  - `data.coupon.discountables.discountable.quickbooks_item` (object,null)
    A record of a QuickBooks item.

  - `data.coupon.discountables.discountable.quickbooks_item.object` (string)
    A canonical value representing a resource.
    Example: "QUICKBOOKS_ITEM"

  - `data.coupon.discountables.discountable.quickbooks_item.id` (string, required)
    ID of the QuickBooks item.
    Example: "1234567890"

  - `data.coupon.discountables.discountable.quickbooks_item.display_name` (string,null)
    Fully qualified display name of the QuickBooks item.
    Example: "Consulting Hours"

  - `data.coupon.discountables.discountable.quickbooks_item.name` (string,null)
    Name of the QuickBooks item.
    Example: "Consulting"

  - `data.coupon.discountables.discountable.quickbooks_item.description` (string,null)
    Description of the QuickBooks item.
    Example: "Hourly consulting services"

  - `data.coupon.discountables.discountable.quickbooks_item.type` (string,null)
    Type of the QuickBooks item.
    Example: "Service"

  - `data.coupon.discountables.discountable.quickbooks_item.active` (boolean)
    Whether the QuickBooks item is active.
    Example: true

  - `data.coupon.discountables.discountable.amount` (number)
    The amount of the item.
    Example: 100

  - `data.coupon.discountables.discountable.name` (string)
    The name of the item.
    Example: "Flat Fee"

  - `data.coupon.times_redeemed` (integer)
    The number of times the coupon has been redeemed.
    Example: 10

  - `data.coupon.created_at` (string,null)
    The date and time (ISO 8601 format) when the order was created.
    Example: "2021-06-30T20:30:00Z"

  - `timestamp` (string,null)
    The request timestamp (ISO 8601).
    Example: "2021-06-30T20:30:00Z"

## Response 403 fields (application/json):

  - `status` (string, required)
    What was the state of the request?
    Example: "error"

  - `message` (string, required)
    The error message.
    Example: "{ApiError message.}"

  - `code` (integer,null)
    A numeric code corresponding to the error.
    Example: 403

## Response 404 fields (application/json):

  - `status` (string, required)
    What was the state of the request?
    Example: "error"

  - `message` (string, required)
    The error message.
    Example: "{ApiError message.}"

  - `code` (integer,null)
    A numeric code corresponding to the error.
    Example: 404

## Response 422 fields (application/json):

  - `status` (string, required)
    What was the state of the request?
    Example: "fail"

## Response 500 fields (application/json):

  - `status` (string, required)
    What was the state of the request?
    Example: "error"

  - `message` (string, required)
    The error message.
    Example: "{ApiError message.}"

  - `code` (integer,null)
    A numeric code corresponding to the error.
    Example: 500


