# Edit Chain Promotion

Endpoint: PUT /chain/{chain_id}/loyalty/programs/{loyalty_program_id}
Version: 1.0.0
Security: BearerPartnerUser

## Security:

  - `BearerPartnerUser` (unknown)
    http bearer Bearer {PartnerToken}, User {UserToken}

## Path parameters:

  - `chain_id` (integer, required)
    Chain ID

  - `loyalty_program_id` (integer, required)
    Promotion ID

## Query parameters:

  - `include` (string)
    Include additional resources in the answer

## Request fields (application/json):

  - `title` (string)
    Share name

  - `usage_limit` (integer)
    Limit on the number of applications (only for cashback)

  - `expiration_timeout` (integer)
    Expiration date of bonuses or discounts

  - `expiration_timeout_unit` (string)
    The unit of measurement for the expiration date of bonuses or discounts
    Enum: "day", "week", "month", "year"

  - `expiration_notification_timeout` (integer)
    How many days before the bonus or discount expires, a notification must be sent to the client

  - `loyalty_card_type_ids` (array)
    Identifiers of types of cards for which the promotion is valid

  - `on_changed_notification_template` (object)
    Body of the request to bind the loyalty notification template
    Example: {"type":"custom","body":"Message text"}

  - `on_changed_notification_template.type` (string)
    Template option
    Enum: "none", "big", "mid", "small", "custom"

  - `on_changed_notification_template.body` (string)
    Template text (custom only)

  - `rules` (array)
    Rules for determining the value of the bonus or discount (only one rule is allowed for fixed promotions)

  - `rules.parameter` (integer)
    Rule Threshold (0 for Fixed Stock Types)

  - `rules.value` (number)
    The value of the discount or bonus

  - `rules.service_id` (integer)
    Service ID (only for "Discount by condition" promotion)

  - `company_ids` (array)
    Identifiers of locations where the promotion is valid

  - `allowed_service_ids` (array)
    Service and service category identifiers (if application type is set for some services)

  - `allowed_good_ids` (array)
    Item IDs (if application type is set for some items)

  - `allowed_good_category_ids` (array)
    Product category identifiers (if application type is set for some products)

## Response 200:

  - `200` (unknown)
    OK

## Response 200 fields (application/json):

  - `id` (integer)
    Stock ID

  - `title` (string)
    Share name

  - `type` (string)
    Promotion type
    Enum: "discount_static", "discount_accumulative_visits", "discount_accumulative_sold", "discount_accumulative_paid", "cashback_static_sold", "cashback_static_paid", "cashback_accumulative_paid", "cashback_accumulative_sold", "cashback_accumulative_paid_visits", "cashback_accumulative_sold_visits", "cashback_sold_visits", "cashback_paid_visits", "package_discount"

  - `service_item_type` (string)
    Type of application to services
    Enum: "any_allowed", "not_allowed", "custom_allowed"

  - `good_item_type` (string)
    Type of application to products
    Enum: "any_allowed", "not_allowed", "custom_allowed"

  - `value_unit` (string)
    Bonus or discount measurement unit (percentage, fixed amount)
    Enum: "percent", "amount"

  - `usage_limit` (integer)
    Limit on the number of applications (only for cashback)

  - `visit_multiplicity` (integer)
    Multiplicity of application by visits (only for cashback)

  - `sold_items_multiplicity` (integer)
    How many services you need to pay to get a discount on promotional services (only for the type of promotion "Discount by condition")

  - `expiration_timeout` (integer)
    Expiration date of bonuses or discounts

  - `expiration_timeout_unit` (string)
    The unit of measurement for the expiration date of bonuses or discounts
    Enum: "day", "week", "month", "year"

  - `expiration_notification_timeout` (integer)
    How many days before the bonus or discount expires, a notification must be sent to the client

  - `params_source_type` (string)
    Where to get the client's history to calculate the size of the bonus or discount (for accumulation promotions or conditional discounts)
    Enum: "loyalty_card", "active_companies", "chain"

  - `history_start_date` (string)
    From what date to take into account the client's history to calculate the size of the bonus or discount (for accumulative promotions or conditional discounts)

  - `on_changed_notification_template_id` (integer)
    Notification template ID when changing bonus or discount

  - `on_expiration_notification_template_id` (integer)
    Identifier of the notification template when a bonus or discount burns

  - `loyalty_card_types` (array)
    Type of cards for which the promotion is valid (on request)

  - `loyalty_card_types.id` (integer)
    Card type identifier

  - `loyalty_card_types.title` (string)
    Card type name

  - `on_changed_notification_template` (object)
    Loyalty notification template
    Example: {"id":12,"type":"small","message_type":"loyalty_discount_expiration","body":"Your discount expires tomorrow"}

  - `on_changed_notification_template.id` (integer)
    Template ID

  - `on_changed_notification_template.type` (string)
    Template option
    Enum: "big", "mid", "small", "custom"

  - `on_changed_notification_template.body` (string)
    Template text

  - `on_changed_notification_template.message_type` (string)
    Message type
    Enum: "loyalty_discount_expiration", "loyalty_cashback_expiration", "loyalty_discount_increased", "loyalty_discount_decreased", "loyalty_card_created", "loyalty_card_withdraw", "loyalty_withdraw_cancelled", "loyalty_card_manual", "loyalty_card_manual_withdraw", "loyalty_card_cashback", "loyalty_card_cashback_cancelled", "loyalty_card_income", "loyalty_discount_changed", "loyalty_cashback_changed", "loyalty_settings_abonement_notification"

  - `rules` (array)
    Rules for determining the value of the bonus or discount (only one rule is allowed for fixed promotions) (on request)

  - `rules.id` (integer)
    Rule ID

  - `rules.parameter` (integer)
    Rule Threshold (0 for Fixed Stock Types)

  - `rules.value` (number)
    The value of the discount or bonus

  - `rules.loyalty_program_id` (integer)
    Loyalty promotion ID

  - `rules.loyalty_type_id` (integer)
    Loyalty promotion type ID

  - `rules.service_id` (integer)
    Service ID (only for "Discount by condition" promotion)

  - `companies` (array)
    Locations where the promotion is valid (on request)

  - `companies.id` (number, required)
    location ID

  - `companies.title` (string, required)
    Name of the organization

  - `companies.country` (string, required)
    The name of the country in which the organization is located

  - `companies.country_id` (number, required)
    Country ID

  - `companies.city` (string, required)
    Name of the city where the organization is located

  - `companies.city_id` (number, required)
    City ID

  - `companies.phone` (string, required)
    location phone

  - `companies.timezone` (string, required)
    location time zone

  - `companies.address` (string, required)
    location address

  - `companies.coordinate_lat` (number, required)
    Latitude

  - `companies.coordinate_lng` (number, required)
    Longitude

  - `applicable_items` (array)
    Related entities for selective application of the promotion (on request)

  - `applicable_items.id` (integer)
    Related entity ID

  - `applicable_items.title` (string)
    Related entity name

  - `applicable_items.is_service` (boolean)
    Flag: true - service/category of services, false - product/category of products

  - `applicable_items.is_category` (boolean)
    Flag: true - service/product category, false - service/product

## Response 422:

  - `422` (unknown)
    Validation error

