---
title: Create or update a promotion
slug: amberflo-api/7083-create-or-update-a-promotion
docTags: 
createdAt: 2024-11-07T15:10:16.972Z
---

{
  "id": "OcCvAxvvsNIgceq94YDFb",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://app.amberflo.io/payments/pricing/amberflo/account-pricing/promotions/relative_product_sales_event_promotion",
    "servers": [
      {
        "url": "https://app.amberflo.io/payments/pricing/amberflo/account-pricing/promotions/relative_product_sales_event_promotion"
      }
    ],
    "name": "Create or update a promotion",
    "description": "",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "optional",
          "name": "body",
          "type": "object",
          "description": "",
          "customType": "payment.pricing.promotions.pre_created.RelativeProductSalesEventPromotion.in",
          "schema": [
            {
              "name": "id",
              "kind": "required",
              "type": "string",
              "description": "Unique id for the promotion.",
              "example": ""
            },
            {
              "name": "type",
              "kind": "optional",
              "type": "string",
              "description": "Promotion type.",
              "example": "",
              "default": "relative_product_sales_event_promotion"
            },
            {
              "name": "promotionName",
              "kind": "required",
              "type": "string",
              "description": "Display name for the promotion.",
              "example": ""
            },
            {
              "name": "description",
              "kind": "optional",
              "type": "string",
              "example": ""
            },
            {
              "name": "lockingStatus",
              "kind": "optional",
              "type": "string",
              "description": "",
              "modelRef": "#/components/schemas/com.amberflo.service.common.LockingStatus.in",
              "customType": "com.amberflo.service.common.LockingStatus.in",
              "schema": []
            },
            {
              "name": "dimensionConstraintMap",
              "kind": "optional",
              "type": "map",
              "description": "If not null, apply promotion to dimensions in map",
              "example": "",
              "customType": "map<string, string>",
              "schema": []
            },
            {
              "name": "customerTags",
              "kind": "optional",
              "type": "map",
              "description": "If not null, apply promotion to customers that match tags",
              "example": "",
              "customType": "map<string, string>",
              "schema": []
            },
            {
              "name": "acceptablePromotionTimeRange",
              "kind": "optional",
              "type": "object",
              "description": "The time range over which to apply the promotion",
              "modelRef": "#/components/schemas/payment.common.TimeRange.in",
              "customType": "payment.common.TimeRange.in",
              "schema": [
                {
                  "name": "startTimeInSeconds",
                  "kind": "optional",
                  "type": "integer<int64>",
                  "example": 0
                },
                {
                  "name": "endTimeInSeconds",
                  "kind": "optional",
                  "type": "integer<int64>",
                  "example": 0
                }
              ]
            },
            {
              "name": "recurrenceInterval",
              "kind": "optional",
              "type": "object",
              "description": "The interval that the promotion recurs over. Defines how often the promotion occurs and the maximum number of times it will occur",
              "modelRef": "#/components/schemas/payment.pricing.promotions.PromotionRecurrenceInterval.in",
              "customType": "payment.pricing.promotions.PromotionRecurrenceInterval.in",
              "schema": [
                {
                  "name": "intervalLength",
                  "kind": "optional",
                  "type": "string",
                  "description": "The length of the interval",
                  "modelRef": "#/components/schemas/payment.pricing.promotions.PromotionRecurringIntervalLength.in",
                  "customType": "payment.pricing.promotions.PromotionRecurringIntervalLength.in",
                  "schema": []
                },
                {
                  "name": "intervalLengthCount",
                  "kind": "optional",
                  "type": "integer<int32>",
                  "description": "The number of interval lengths in the interval",
                  "example": 0
                },
                {
                  "name": "maxRecurrence",
                  "kind": "optional",
                  "type": "integer<int32>",
                  "description": "The max number of intervals that the promotion will occur over",
                  "example": 0
                }
              ]
            },
            {
              "name": "discountRatio",
              "kind": "optional",
              "type": "number",
              "description": "The amount of discount for the promotion",
              "example": ""
            },
            {
              "name": "totalMaxDiscount",
              "kind": "optional",
              "type": "number",
              "description": "The maximum amount of discount that can be applied",
              "example": ""
            },
            {
              "name": "cycleMaxDiscount",
              "kind": "optional",
              "type": "number",
              "description": "The maximum amount of discount that can be applied per billing cycle",
              "example": ""
            },
            {
              "name": "targetProductId",
              "kind": "optional",
              "type": "string",
              "description": "The product that we want to apply the promotion on",
              "example": ""
            }
          ],
          "modelRef": "#/components/schemas/payment.pricing.promotions.pre_created.RelativeProductSalesEventPromotion.in",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "apiKey",
          "name": "X-API-KEY",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        }
      ]
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Successful request",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "payment.pricing.promotions.pre_created.RelativeProductSalesEventPromotion.out",
            "schema": [
              {
                "name": "id",
                "kind": "required",
                "type": "string",
                "description": "Unique id for the promotion.",
                "example": ""
              },
              {
                "name": "type",
                "kind": "optional",
                "type": "string",
                "description": "Promotion type.",
                "example": "",
                "default": "relative_product_sales_event_promotion"
              },
              {
                "name": "promotionName",
                "kind": "required",
                "type": "string",
                "description": "Display name for the promotion.",
                "example": ""
              },
              {
                "name": "description",
                "kind": "optional",
                "type": "string",
                "example": ""
              },
              {
                "name": "lockingStatus",
                "kind": "optional",
                "type": "string",
                "description": "",
                "modelRef": "#/components/schemas/com.amberflo.service.common.LockingStatus.out",
                "customType": "com.amberflo.service.common.LockingStatus.out",
                "schema": []
              },
              {
                "name": "lastUpdateTimeInMillis",
                "kind": "optional",
                "type": "integer<int64>",
                "description": "Last update time, in [Unix time](https://en.wikipedia.org/wiki/Unix_time) (milliseconds).",
                "example": 0
              },
              {
                "name": "dimensionConstraintMap",
                "kind": "optional",
                "type": "map",
                "description": "If not null, apply promotion to dimensions in map",
                "example": "",
                "customType": "map<string, string>",
                "schema": []
              },
              {
                "name": "customerTags",
                "kind": "optional",
                "type": "map",
                "description": "If not null, apply promotion to customers that match tags",
                "example": "",
                "customType": "map<string, string>",
                "schema": []
              },
              {
                "name": "acceptablePromotionTimeRange",
                "kind": "optional",
                "type": "object",
                "description": "The time range over which to apply the promotion",
                "modelRef": "#/components/schemas/payment.common.TimeRange.out",
                "customType": "payment.common.TimeRange.out",
                "schema": [
                  {
                    "name": "startTimeInSeconds",
                    "kind": "optional",
                    "type": "integer<int64>",
                    "example": 0
                  },
                  {
                    "name": "endTimeInSeconds",
                    "kind": "optional",
                    "type": "integer<int64>",
                    "example": 0
                  }
                ]
              },
              {
                "name": "recurrenceInterval",
                "kind": "optional",
                "type": "object",
                "description": "The interval that the promotion recurs over. Defines how often the promotion occurs and the maximum number of times it will occur",
                "modelRef": "#/components/schemas/payment.pricing.promotions.PromotionRecurrenceInterval.out",
                "customType": "payment.pricing.promotions.PromotionRecurrenceInterval.out",
                "schema": [
                  {
                    "name": "intervalLength",
                    "kind": "optional",
                    "type": "string",
                    "description": "The length of the interval",
                    "modelRef": "#/components/schemas/payment.pricing.promotions.PromotionRecurringIntervalLength.out",
                    "customType": "payment.pricing.promotions.PromotionRecurringIntervalLength.out",
                    "schema": []
                  },
                  {
                    "name": "intervalLengthCount",
                    "kind": "optional",
                    "type": "integer<int32>",
                    "description": "The number of interval lengths in the interval",
                    "example": 0
                  },
                  {
                    "name": "maxRecurrence",
                    "kind": "optional",
                    "type": "integer<int32>",
                    "description": "The max number of intervals that the promotion will occur over",
                    "example": 0
                  }
                ]
              },
              {
                "name": "discountRatio",
                "kind": "optional",
                "type": "number",
                "description": "The amount of discount for the promotion",
                "example": ""
              },
              {
                "name": "totalMaxDiscount",
                "kind": "optional",
                "type": "number",
                "description": "The maximum amount of discount that can be applied",
                "example": ""
              },
              {
                "name": "cycleMaxDiscount",
                "kind": "optional",
                "type": "number",
                "description": "The maximum amount of discount that can be applied per billing cycle",
                "example": ""
              },
              {
                "name": "targetProductId",
                "kind": "optional",
                "type": "string",
                "description": "The product that we want to apply the promotion on",
                "example": ""
              }
            ],
            "modelRef": "#/components/schemas/payment.pricing.promotions.pre_created.RelativeProductSalesEventPromotion.out",
            "isExpanded": true
          }
        ]
      }
    ],
    "examples": {
      "languages": [
        {
          "id": "zn-aUd3EvefXQzaOVmZq7",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://app.amberflo.io/payments/pricing/amberflo/account-pricing/promotions/relative_product_sales_event_promotion \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"id\": \"\",\n     \"type\": \"relative_product_sales_event_promotion\",\n     \"promotionName\": \"\"\n     }'"
        },
        {
          "id": "eC-NPt5pkXtjlORO2L94D",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar raw = JSON.stringify({\n   \"id\": \"\",\n   \"type\": \"relative_product_sales_event_promotion\",\n   \"promotionName\": \"\"\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://app.amberflo.io/payments/pricing/amberflo/account-pricing/promotions/relative_product_sales_event_promotion\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "GGwkSAMMDgUymYeHw2W_R",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://app.amberflo.io/payments/pricing/amberflo/account-pricing/promotions/relative_product_sales_event_promotion\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\nrequest.body = JSON.dump({\n   \"id\": \"\",\n   \"type\": \"relative_product_sales_event_promotion\",\n   \"promotionName\": \"\"\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "ziOKr2xGA93YRzfqqvTVX",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://app.amberflo.io/payments/pricing/amberflo/account-pricing/promotions/relative_product_sales_event_promotion\"\n\npayload = json.dumps({\n   \"id\": \"\",\n   \"type\": \"relative_product_sales_event_promotion\",\n   \"promotionName\": \"\"\n})\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "zn-aUd3EvefXQzaOVmZq7"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// Successful request\n{\n  \"id\": \"\",\n  \"type\": \"\",\n  \"promotionName\": \"\",\n  \"description\": \"\",\n  \"lockingStatus\": \"\",\n  \"lastUpdateTimeInMillis\": \"\",\n  \"dimensionConstraintMap\": \"\",\n  \"customerTags\": \"\",\n  \"acceptablePromotionTimeRange\": {\n    \"startTimeInSeconds\": \"\",\n    \"endTimeInSeconds\": \"\"\n  },\n  \"recurrenceInterval\": {\n    \"intervalLength\": \"\",\n    \"intervalLengthCount\": \"\",\n    \"maxRecurrence\": \"\"\n  },\n  \"discountRatio\": 0,\n  \"totalMaxDiscount\": 0,\n  \"cycleMaxDiscount\": 0,\n  \"targetProductId\": \"\"\n}"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}