---
title: Order Purchase/Return/Refund/Cancellation
slug: data-platform/api/order-purchasereturnrefundcancellation
docTags: 
createdAt: 2026-09-02T14:41:00.110Z
---

{
  "id": "c-i8IymnsihdzyZ9pZ0PU",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://api.us1.odp.optimizely.com/v3/events",
    "servers": [
      {
        "url": "https://api.us1.odp.optimizely.com/v3/events",
        "description": "United States"
      },
      {
        "url": "https://api.eu1.odp.optimizely.com/v3/events",
        "description": "Europe"
      },
      {
        "url": "https://api.au1.odp.optimizely.com/v3/events",
        "description": "Asia-Pacific"
      }
    ],
    "name": "Order Purchase/Return/Refund/Cancellation",
    "description": "<p>Upload an order purchase/return/refund/cancellation event to Optimizely Data Platform (ODP).</p>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [
        {
          "name": "accept",
          "type": "string",
          "kind": "optional",
          "description": "Generated from available response content types",
          "enum": [
            "application/json"
          ],
          "default": "application/json"
        }
      ],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "body",
          "type": "array",
          "example": "[{\"type\":\"order\",\"action\":\"purchase\",\"identifiers\":{\"email\":\"bob@gmail.com\"},\"data\":{\"ts\":123456789,\"order\":{\"order_id\":\"OR345\",\"total\":109.65,\"discount\":5,\"subtotal\":103,\"tax\":5.15,\"shipping\":6.5,\"coupon_code\":\"5OFF\",\"items\":[{\"product_id\":\"2045\",\"price\":19,\"quantity\":5,\"discount\":0,\"subtotal\":95},{\"product_id\":\"2091\",\"price\":10,\"quantity\":1,\"discount\":2,\"subtotal\":8}]}}}]",
          "examples": [
            {
              "label": "Order Purchase Example Payload",
              "value": "[{\"type\":\"order\",\"action\":\"purchase\",\"identifiers\":{\"email\":\"bob@gmail.com\"},\"data\":{\"ts\":123456789,\"order\":{\"order_id\":\"OR345\",\"total\":109.65,\"discount\":5,\"subtotal\":103,\"tax\":5.15,\"shipping\":6.5,\"coupon_code\":\"5OFF\",\"items\":[{\"product_id\":\"2045\",\"price\":19,\"quantity\":5,\"discount\":0,\"subtotal\":95},{\"product_id\":\"2091\",\"price\":10,\"quantity\":1,\"discount\":2,\"subtotal\":8}]}}}]"
            },
            {
              "label": "Order Cancellation Example Payload",
              "value": "[{\"type\":\"order\",\"action\":\"cancel\",\"identifiers\":{\"email\":\"bob@gmail.com\"},\"data\":{\"ts\":123456789,\"order\":{\"order_id\":\"OR345\",\"total\":-100,\"items\":[{\"product_id\":\"2045\",\"price\":-10,\"quantity\":10,\"subtotal\":-100}]}}}]"
            },
            {
              "label": "Partial Refund Example Payload",
              "value": "[{\"identifiers\":{\"email\":\"bob@thebuyer.com\"},\"type\":\"order\",\"action\":\"refund\",\"data\":{\"order\":{\"order_id\":\"ABC\",\"total\":10,\"subtotal\":10}}}]"
            }
          ],
          "description": "",
          "customType": "Event[]",
          "schema": [
            {
              "name": "type",
              "kind": "required",
              "type": "string",
              "description": "the event type",
              "example": "order",
              "default": "order"
            },
            {
              "name": "action",
              "kind": "required",
              "type": "string",
              "description": "<p>the event action associated with the type.  Acceptable actions include: <code>purchase</code>, <code>return</code>, <code>refund</code>, and <code>cancel</code></p>",
              "example": "purchase"
            },
            {
              "name": "identifiers",
              "kind": "required",
              "type": "map",
              "description": "any known identifiers associated with the customer that performed the event",
              "example": "",
              "customType": "map<string, string>",
              "schema": []
            },
            {
              "name": "data",
              "kind": "optional",
              "type": "map",
              "description": "the data with the order and any additional fields",
              "example": "",
              "customType": "map<string, string>",
              "schema": [
                {
                  "name": "ts",
                  "kind": "optional",
                  "type": "number",
                  "description": "specify the time of the order action"
                },
                {
                  "name": "order",
                  "kind": "optional",
                  "type": "object",
                  "description": "",
                  "modelRef": "#/components/schemas/Order",
                  "customType": "Order",
                  "schema": [
                    {
                      "name": "order_id",
                      "kind": "required",
                      "type": "string",
                      "description": "the unique identifier related to this order"
                    },
                    {
                      "name": "total",
                      "kind": "optional",
                      "type": "number",
                      "description": "<p>total should include the final amount charged to the customer after all goods, discounts, tax, and shipping are calculated. See below for more information</p>"
                    },
                    {
                      "name": "subtotal",
                      "kind": "optional",
                      "type": "number",
                      "description": "<p>subtotal may be taken either before or after discounting, but generally should be before shipping or tax</p>"
                    },
                    {
                      "name": "tax",
                      "kind": "optional",
                      "type": "number",
                      "description": ""
                    },
                    {
                      "name": "shipping",
                      "kind": "optional",
                      "type": "number",
                      "description": ""
                    },
                    {
                      "name": "items",
                      "kind": "optional",
                      "type": "array",
                      "description": "",
                      "modelRef": "#/components/schemas/LineItem",
                      "customType": "LineItem[]",
                      "schema": [
                        {
                          "name": "product_id",
                          "kind": "required",
                          "type": "string",
                          "description": "the unique identifier for the order line item"
                        },
                        {
                          "name": "price",
                          "kind": "optional",
                          "type": "number",
                          "description": "the price for an order line item"
                        },
                        {
                          "name": "quantity",
                          "kind": "optional",
                          "type": "number",
                          "description": "the number of items purchased"
                        },
                        {
                          "name": "discount",
                          "kind": "optional",
                          "type": "number",
                          "description": "<p>the discount (if any) for the given line item</p>"
                        },
                        {
                          "name": "subtotal",
                          "kind": "optional",
                          "type": "number",
                          "description": "<p>the calculated subtotal for the given product and quantity, typically calculated after any discounts</p>"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ],
          "modelRef": "#/components/schemas/Event",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "x-api-key",
          "name": "x-api-key",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "202",
        "description": "Accepted",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "GenericUpdateResponse",
            "schema": [
              {
                "name": "title",
                "kind": "optional",
                "type": "string",
                "description": ""
              },
              {
                "name": "status",
                "kind": "optional",
                "type": "integer<int32>",
                "description": "",
                "format": "int32"
              },
              {
                "name": "timestamp",
                "kind": "optional",
                "type": "string",
                "description": ""
              }
            ],
            "modelRef": "#/components/schemas/GenericUpdateResponse",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "Bad Request",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "undefined",
            "example": "{\"title\":\"Bad Request\",\"status\":400,\"timestamp\":\"2018-09-10T21:07:10-05:00\",\"detail\":{\"invalids\":[{\"field\":\"delimiter\",\"reason\":\"Unrecognized delimiter, valid options are comma, tab or pipe\"}]}}",
            "description": "",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "403",
        "description": "Forbidden",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "undefined",
            "example": "{  \"message\": \"Forbidden\"}",
            "description": "",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "404",
        "description": "Not Found",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "undefined",
            "example": "{\"title\":\"Bad Request\",\"status\":404,\"timestamp\":\"2018-09-10T21:07:10-05:00\",\"detail\":{\"message\":\"Not found description\"}}",
            "description": "",
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "D8aDXRfsWYPpSvUXwt2Fa",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.us1.odp.optimizely.com/v3/events \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '[\n     {\n     \"type\": \"order\",\n     \"action\": \"purchase\",\n     \"identifiers\": \"\",\n     \"data\": \"\"\n     }\n     ]'"
        },
        {
          "id": "PGfKX_H8qvXrFxt9foior",
          "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   {\n      \"type\": \"order\",\n      \"action\": \"purchase\",\n      \"identifiers\": \"\",\n      \"data\": \"\"\n   }\n]);\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.us1.odp.optimizely.com/v3/events\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "e5x9S5LIYEfe3CEetUPlc",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.us1.odp.optimizely.com/v3/events\")\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   {\n      \"type\": \"order\",\n      \"action\": \"purchase\",\n      \"identifiers\": \"\",\n      \"data\": \"\"\n   }\n])\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "RpZeUFH3o04FmYMM_KuZc",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.us1.odp.optimizely.com/v3/events\"\n\npayload = json.dumps([\n   {\n      \"type\": \"order\",\n      \"action\": \"purchase\",\n      \"identifiers\": \"\",\n      \"data\": \"\"\n   }\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": "D8aDXRfsWYPpSvUXwt2Fa"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-202",
          "language": "202",
          "code": "// Accepted\n{\n  \"title\": \"\",\n  \"status\": \"\",\n  \"timestamp\": \"\"\n}"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// Bad Request\n\"{\\\"title\\\":\\\"Bad Request\\\",\\\"status\\\":400,\\\"timestamp\\\":\\\"2018-09-10T21:07:10-05:00\\\",\\\"detail\\\":{\\\"invalids\\\":[{\\\"field\\\":\\\"delimiter\\\",\\\"reason\\\":\\\"Unrecognized delimiter, valid options are comma, tab or pipe\\\"}]}}\""
        },
        {
          "id": "response-2-403",
          "language": "403",
          "code": "// Forbidden\n\"{  \\\"message\\\": \\\"Forbidden\\\"}\""
        },
        {
          "id": "response-3-404",
          "language": "404",
          "code": "// Not Found\n\"{\\\"title\\\":\\\"Bad Request\\\",\\\"status\\\":404,\\\"timestamp\\\":\\\"2018-09-10T21:07:10-05:00\\\",\\\"detail\\\":{\\\"message\\\":\\\"Not found description\\\"}}\""
        }
      ],
      "selectedLanguageId": "response-0-202"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}