> For the complete documentation index, see [llms.txt](https://apidocs.akinon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs.akinon.com/commerce/users/user-orders-and-cancellations.md).

# User Orders & Cancellations

### `GET` List User Orders

This endpoint allows an authenticated user to retrieve a list of all their orders..

**Path:** `/users/orders/`

**Authentication Required:** Yes

**Headers:**

```
Accept-Language: <iso_language_code>
Cookie: <cookie-name>=<session_id>
```

**Query Parameters**

| Parameter              | Type                | Required | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ---------------------- | ------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `status`               | string (repeatable) | No       | Filter by one or more order statuses. Accepted values: `50` (cancellation\_waiting), `100` (cancelled), `200` (waiting), `300` (payment\_waiting), `350` (confirmation\_waiting), `400` (approved), `430` (waiting\_for\_substitute), `450` (preparing), `500` (shipped), `510` (shipped\_and\_informed), `520` (ready\_for\_pickup), `540` (attempted\_delivery), `544` (review\_started), `545` (review\_waiting), `546` (waiting\_for\_payment), `547` (paid), `550` (delivered), `600` (refunded), `700` (merged). Example: `?status=100&status=600` |
| `cancellation_type`    | string (repeatable) | No       | Filter orders that have cancellation requests of the given type(s). Accepted values: `cancel`, `refund`. Example: `?cancellation_type=cancel&cancellation_type=refund`                                                                                                                                                                                                                                                                                                                                                                                   |
| `currency`             | string              | No       | Filter by currency code. Accepted values: `try`, `eur`, `usd`, `egp`, `gbp`, `mad`, `pln`, `sar`, `ron`, `uah`, `czk`, `huf`, `rub`, `bgn`, `iqd`, `kwd`, `bhd`, `omr`, `qar`, `aed`, `ngn`, `inr`, `lei`, `kzt`, `jod`, `rsd`, `amd`, `cfa`, `lyd`.                                                                                                                                                                                                                                                                                                     |
| `shipping_option_id`   | integer             | No       | Filter by shipping option ID.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `shipping_option_slug` | string              | No       | Filter by shipping option slug (partial match).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `last_month`           | boolean             | No       | If `true`, returns only orders from the last 30 days.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `search`               | string              | No       | Search by order number.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `page`                 | integer             | No       | Page number for pagination.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |

**Example Request**

```py
import requests

url = "https://{commerce_url}/users/orders/"

headers = {
   'Accept-Language': '<iso_language_code>',
   'Cookie': '<cookie-name>=<session_id>'
}

response = requests.get(url, headers=headers)

print(response.text)
```

**Example Response (200 OK)**

```json
{
    "count": 7,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 6016,
            "status": {},
            "currency": {},
            "orderitem_set": [],
            "discountitem_set": [],
            "is_cancelled": true,
            "is_cancellable": false,
            "is_refundable": false,
            "shipping_address": {},
            "billing_address": {},
            "shipping_company": null,
            "client_type": "default",
            "payment_option": {},
            "amount_without_discount": "109.99",
            "is_payable": false,
            "tracking_url": null,
            "bank": {},
            "loyaltytransaction_set": [],
            "created_date": "2024-10-24T09:32:05.544358Z",
            "modified_date": "2024-11-05T08:53:25.564365Z",
            "number": "2745403029312170",
            "amount": "99.99",
            "discount_amount": "10.00",
            "shipping_amount": "0.00",
            "shipping_tax_rate": null,
            "refund_amount": "99.99",
            "discount_refund_amount": "0.00",
            "shipping_refund_amount": "0.00",
            "invoice_number": null,
            "invoice_date": null,
            "e_archive_url": null,
            "tracking_number": null,
            "defined_tracking_url": null,
            "remote_addr": "3.73.5.7",
            "has_gift_box": false,
            "gift_box_note": null,
            "language_code": "en-us",
            "notes": null,
            "delivery_range": null,
            "extra_field": {},
            "user_email": "john.doe@akinon.com",
            "shipping_option_slug": "TEST-123",
            "payment_option_slug": "Credit_Card",
            "bin_number": "555555",
            "installment_count": 1,
            "installment_interest_amount": "0.00",
            "shipping_tracking_url": null,
            "user": 6471,
            "basket": 9901,
            "shipping_option": 232,
            "card": 364,
            "installment": 265,
            "segment": null,
            "checkout_provider": null
        }
    ]
}
```

### `GET` Retrieve User Order

This endpoint allows you to retrieve detailed information about a specific user's order using the order ID (`<pk>`).

**Path:** `/users/orders/<pk>/`

**Authentication Required:** Yes

**Headers:**

```
Accept-Language: <iso_language_code>
Cookie: <cookie-name>=<session_id>
```

**Example Request**

```py
import requests

url = "https://{commerce_url}/users/orders/<pk>/"

headers = {
    'Accept-Language': '<iso_language_code>',
    'Cookie': '<cookie-name>=<session_id>'
}

response = requests.get(url, headers=headers)

print(response.text)
```

**Example Response (200 OK)**

```json
{
    "id": 1,
    "status": {
        "value": "200",
        "label": "Bekliyor"
    },
    "currency": {
        "value": "try",
        "label": "TL"
    },
    "orderitem_set": [
        {
            "id": 485,
            "status": {
                "value": "200",
                "label": "Bekliyor"
            },
            "price_currency": {
                "value": "try",
                "label": "TL"
            },
            "product": {
                "pk": 4283,
                "sku": "2672881068196",
                "base_code": "1KPARF0006",
                "name": "Repertoıre Room Spray 100 Ml",
                "image": "https://akinon.net/products/2017/01/23/6/fb8a31.jpg",
                "absolute_url": "/repertoire-room-spray-100-ml-violet/",
                "attributes": {
                    "integration_ProductAtt12Desc": "%50 + %50 PROMOSYON",
                    "uretim_yeri": "TÜRKİYE"
                },
                "attributes_kwargs": {
                    "erp_ProductHierarchyLevel01": {
                        "value": "KOZMETİK",
                        "data_type": "dropdown",
                        "label": "KOZMETİK"
                    }
                },
                "form_schema": null,
                "data_source": null,
                "extra_attributes": {}
            },
            "is_cancelled": false,
            "is_cancellable": true,
            "is_refundable": false,
            "cancellationrequest_set": [],
            "active_cancellation_request": null,
            "shipping_company": null,
            "tracking_url": null,
            "is_tradable": false,
            "available_easy_return_shipping_companies": [],
            "datasource_detailed": null,
            "extra_product_stock_detailed": null,
            "extra_product_price_detailed": null,
            "created_date": "2021-05-24T08:26:12.213928Z",
            "modified_date": "2021-05-24T08:26:12.213957Z",
            "attributes": {},
            "attributes_kwargs": {},
            "localized_attributes": {},
            "localized_attributes_kwargs": {},
            "price": "11.87",
            "tax_rate": "18.00",
            "invoice_number": null,
            "invoice_date": null,
            "e_archive_url": null,
            "tracking_number": null,
            "retail_price": "47.47",
            "image": null,
            "extra_field": {
                "price_extra_field": {},
                "stock_extra_field": {}
            },
            "estimated_delivery_date": null,
            "shipping_tracking_url": null,
            "order": 388,
            "parent": null,
            "extra_product_price": null,
            "extra_product_stock": null,
            "datasource": null
        }
    ],
    "discountitem_set": [],
    "is_cancelled": false,
    "is_cancellable": true,
    "is_refundable": false,
    "shipping_address": {
        "pk": 63,
        "email": "testtest@test.com",
        "phone_number": "05555555555",
        "first_name": "Test",
        "last_name": "Test",
        "country": {
            "pk": 1,
            "is_active": true,
            "name": "Türkiye",
            "code": "tr",
            "translations": null
        },
        "city": {
            "pk": 13,
            "is_active": true,
            "name": "Adana",
            "country": 1,
            "translations": null,
            "priority": null,
            "postcode": null
        },
        "line": "Test test test",
        "title": "Test",
        "township": {
            "pk": 271,
            "is_active": true,
            "name": "Test Name",
            "city": 13,
            "postcode": null
        },
        "district": {
            "pk": 3978,
            "is_active": true,
            "name": "Test",
            "city": 13,
            "township": 271,
            "postcode": null
        },
        "postcode": "61000",
        "notes": null,
        "company_name": "",
        "tax_office": "",
        "tax_no": "",
        "e_bill_taxpayer": false,
        "hash_data": "6800dd08a0d375b1d2016bbb3d6125f2",
        "address_type": "customer",
        "retail_store": null,
        "remote_id": null,
        "identity_number": null,
        "extra_field": null,
        "user": <user_data>,
        "is_corporate": false,
        "primary": false
    },
    "billing_address": {
        "pk": 63,
        "email": "testtest@test.com",
        "phone_number": "05555555555",
        "first_name": "Test",
        "last_name": "Test",
        "country": {
            "pk": 1,
            "is_active": true,
            "name": "Türkiye",
            "code": "tr",
            "translations": null
        },
        "city": {
            "pk": 13,
            "is_active": true,
            "name": "Adana",
            "country": 1,
            "translations": null,
            "priority": null,
            "postcode": null
        },
        "line": "Test test test",
        "title": "Test",
        "township": {
            "pk": 271,
            "is_active": true,
            "name": "Test Name",
            "city": 13,
            "postcode": null
        },
        "district": {
            "pk": 3978,
            "is_active": true,
            "name": "KALDIRIM",
            "city": 13,
            "township": 271,
            "postcode": null
        },
        "postcode": "61000",
        "notes": null,
        "company_name": "",
        "tax_office": "",
        "tax_no": "",
        "e_bill_taxpayer": false,
        "hash_data": "6800dd08a0d375b1d2016bbb3d6125f2",
        "address_type": "customer",
        "retail_store": null,
        "remote_id": null,
        "identity_number": null,
        "extra_field": null,
        "user": <user_data>,
        "is_corporate": false,
        "primary": false
    },
    "shipping_company": null,
    "client_type": "default",
    "payment_option": {
        "pk": 18,
        "name": "Garanti Switch",
        "payment_type": "saved_card",
        "slug": "gswitch"
    },
    "amount_without_discount": "20.37",
    "is_payable": false,
    "tracking_url": null,
    "bank": {
        "pk": 5,
        "name": "Garanti Bankası",
        "slug": "garanti-bankas",
        "logo": null
    },
    "created_date": "2021-05-24T08:26:12.205731Z",
    "modified_date": "2021-05-24T08:26:12.205783Z",
    "number": "1666226475313376",
    "amount": "20.37",
    "discount_amount": "0.00",
    "shipping_amount": "8.50",
    "shipping_tax_rate": null,
    "refund_amount": "0.00",
    "discount_refund_amount": "0.00",
    "shipping_refund_amount": "0.00",
    "invoice_number": null,
    "invoice_date": null,
    "e_archive_url": null,
    "tracking_number": null,
    "remote_addr": "61.61.61.61",
    "has_gift_box": false,
    "gift_box_note": null,
    "language_code": "tr-tr",
    "notes": null,
    "delivery_range": null,
    "extra_field": null,
    "user_email": "testtest@test.com",
    "shipping_option_slug": "ARAS",
    "payment_option_slug": "gswitch",
    "bin_number": "554960",
    "installment_count": 1,
    "installment_interest_amount": "0.00",
    "shipping_tracking_url": null,
    "user": 1,
    "basket": 529,
    "shipping_option": 1,
    "card": 5,
    "installment": 5,
    "segment": null,
    "checkout_provider": null
}
```

### `GET` Display Return Items for Order Cancellation

This endpoint is used to list and display the return items for a specific order on the shop page, showing information about cancelled items and their details.

**Path:** `/users/orders/<pk>/cancellation/`

**Authentication Required:** Yes

**Headers:**

```
Accept-Language: <iso_language_code>
Cookie: <cookie-name>=<session_id>
```

**Example Request**

```py
import requests

url = "https://{commerce_url}/users/orders/<pk>/cancellation/"

headers = {
    'Accept-Language': '<iso_language_code>',
    'Cookie': '<cookie-name>=<session_id>'
}

response = requests.get(url, headers=headers)

print(response.text)
```

**Example Response (200 OK)**

```json
{
    "id": 940901,
    "status": {
        "value": "100",
        "label": "İptal edildi"
    },
    "currency": {
        "value": "try",
        "label": "TL"
    },
    "orderitem_set": [
        {
            "id": 1826154,
            "status": {
                "value": "100",
                "label": "İptal edildi"
            },
            "price_currency": {
                "value": "try",
                "label": "TL"
            },
            "product": {
                "pk": 424106,
                "sku": "4759302",
                "base_code": "W35517T",
                "name": "Erkek Kırmızı Classic Fit Uzun Kollu Keten Gömlek",
                "image": "https://akn-occ.a-cdn/products/4-4f2ad1d7.jpg",
                "absolute_url": "gomlek-w35517t",
                "attributes": {
                    "integration_kalip": "CLASSIC FIT",
                },
                "attributes_kwargs": {
                    "integration_beden_seti": {
                        "value": "0",
                        "data_type": "dropdown",
                        "label": "0"
                    },
            },
            "is_cancelled": true,
            "is_cancellable": false,
            "is_refundable": false,
            "cancellationrequest_set": [],
            "active_cancellation_request": null,
            "shipping_company": null,
            "tracking_url": null,
            "is_tradable": false,
            "available_easy_return_shipping_companies": [
                {
                    "pk": 1,
                    "shipping_company": {
                        "value": "yurtici",
                        "label": "Yurtiçi Kargo"
                    },
                    "name": "2"
                }
            ],
            "datasource_detailed": null,
            "extra_product_stock_detailed": null,
            "extra_product_price_detailed": null,
            "shipping_option_group": null,
            "created_date": "2024-11-14T10:39:48.610172Z",
            "modified_date": "2024-11-14T11:19:16.515342Z",
            "attributes": {},
            "attributes_kwargs": {},
            "localized_attributes": {},
            "localized_attributes_kwargs": {},
            "price": "999.00",
            "tax_rate": "10.00",
            "invoice_number": null,
            "invoice_date": null,
            "e_archive_url": null,
            "tracking_number": null,
            "defined_tracking_url": null,
            "retail_price": "2799.00",
            "image": null,
            "extra_field": {
                "price_extra_field": {},
                "stock_extra_field": {}
            },
            "estimated_delivery_date": null,
            "shipping_tracking_url": null,
            "order": 940901,
            "parent": null,
            "extra_product_price": null,
            "extra_product_stock": null,
            "datasource": null
        }
    ],
    "discountitem_set": [
        {
            "name": "Sepette %40 İndirim",
            "amount": "399.60",
            "created_date": "2024-11-14T10:39:48.616579Z",
            "order_number": "2763587084514370",
            "currency": {
                "value": "try",
                "label": "TL"
            }
        },
        {
            "name": "VIP Özel Kargo Bedava",
            "amount": "0.00",
            "created_date": "2024-11-14T10:39:48.624229Z",
            "order_number": "2763587084514370",
            "currency": {
                "value": "try",
                "label": "TL"
            }
        }
    ],
    "is_cancelled": true,
    "is_cancellable": false,
    "is_refundable": false,
    "shipping_address": {
        "pk": 549671,
        "email": "test.test@test.com",
        "phone_number": "00000000000",
        "first_name": "John",
        "last_name": "Doe",
        "country": {
            "pk": 1,
            "is_active": true,
            "name": "Türkiye",
            "code": "tr",
            "translations": null
        },
        "city": {
            "pk": 60,
            "is_active": true,
            "name": "İSTANBUL",
            "country": 1,
            "translations": null,
            "priority": null,
            "postcode": null
        },
        "line": "Bağcılar/İstanbu",
        "title": "Depo",
        "township": {
            "pk": 451,
            "is_active": true,
            "name": "BAĞCILAR",
            "city": 60,
            "postcode": null,
            "translations": null
        },
        "district": {
            "pk": 35498,
            "is_active": true,
            "name": "MAH",
            "city": 60,
            "township": 451,
            "postcode": null,
            "translations": null
        },
        "postcode": "",
        "notes": null,
        "company_name": "",
        "tax_office": "",
        "tax_no": "",
        "e_bill_taxpayer": false,
        "hash_data": "86c056fb6d8b3",
        "address_type": "customer",
        "retail_store": null,
        "remote_id": null,
        "identity_number": null,
        "extra_field": null,
        "user": {
            "pk": 558297,
            "username": "61846705af4b21dd5fb7aab6b1b771cb",
            "first_name": "John",
            "last_name": "Doe",
            "email": "test.test@test.com",
            "is_active": true,
            "date_joined": "2023-06-14T07:27:17.917188Z",
            "last_login": "2024-11-19T13:48:39.198058Z",
            "email_allowed": true,
            "sms_allowed": true,
            "call_allowed": true,
            "gender": "female",
            "attributes": {
                "sap_id": "6764a455e-081da2e9d3ce",
                "logged_ip": "176.41.42.87",
            },
            "phone": "0000000",
            "date_of_birth": "1999-06-10",
            "attributes_kwargs": {},
            "user_type": "registered",
            "modified_date": "2024-07-31T10:56:45.221522Z"
        },
        "is_corporate": false,
        "primary": false
    },
    "billing_address": <address_data>,
    "shipping_company": null,
    "client_type": "ios",
    "payment_option": {
        "pk": 69,
        "name": "Kredi Kartı İle Öde",
        "payment_type": "masterpass",
        "slug": "masterpass"
    },
    "amount_without_discount": "999.00",
    "is_payable": false,
    "tracking_url": null,
    "bank": <bank_data>,
    "loyaltytransaction_set": [],
    "created_date": "2024-11-14T10:39:48.599642Z",
    "modified_date": "2024-11-14T11:18:56.641719Z",
    "number": "2763587084514370",
    "amount": "599.40",
    "discount_amount": "399.60",
    "shipping_amount": "0.00",
    "shipping_tax_rate": null,
    "refund_amount": "599.40",
    "discount_refund_amount": "0.00",
    "shipping_refund_amount": "0.00",
    "invoice_number": null,
    "invoice_date": null,
    "e_archive_url": null,
    "tracking_number": null,
    "defined_tracking_url": null,
    "remote_addr": "95.7.2.199",
    "has_gift_box": false,
    "gift_box_note": null,
    "language_code": "tr-tr",
    "notes": null,
    "delivery_range": null,
    "extra_field": {},
    "user_email": "test.test@test.com",
    "shipping_option_slug": "yurtici",
    "payment_option_slug": "masterpass",
    "bin_number": "454",
    "installment_count": 1,
    "installment_interest_amount": "0.00",
    "shipping_tracking_url": null,
    "user": 558297,
    "basket": 4149068,
    "shipping_option": 1,
    "card": 18,
    "installment": 18,
    "segment": null,
    "checkout_provider": null
}
```

### `POST` User Bulk Create Cancellation Requests

This endpoint allows for creating cancellation requests for multiple orders at once.

**Path:** `/users/orders/bulk_cancellation_requests/`

**Authentication Required:** Yes

**Headers:**

```
Content-Type: application/json
Accept-Language: <iso_language_code>
Cookie: <cookie-name>=<session_id>
x-csrftoken: <token>
```

**Body Parameters**

| Property                                            | Data Type | Required | Description                                                                                                                                                                   |
| --------------------------------------------------- | --------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| cancel\_order\_items.cancellation\_type             | enum      | True     | Type of cancellations. Possible values are “cancel” and “refund”.                                                                                                             |
| cancel\_order\_items.quantity                       | integer   | False    | Specifies the quantity of the order items that are to be cancelled. This field is optional and can be left empty unless a specific quantity is required for the cancellation. |
| cancel\_order\_items.description                    | string    | False    | An optional description or message explaining the reason for cancellation.                                                                                                    |
| cancel\_order\_items.order\_item                    | integer   | True     | The ID of the order item to be cancelled.                                                                                                                                     |
| cancel\_order\_items.shipping\_company              | integer   | False    | The ID of the Shipping Company (if applicable).                                                                                                                               |
| cancel\_order\_items.iban                           | String    | False    | The IBAN number for the refund (if applicable).                                                                                                                               |
| cancel\_order\_items.holder\_name                   | String    | False    | The name of the account holder for refunding (if applicable).                                                                                                                 |
| cancel\_order\_items.pickup\_date.date              | date      | False    | Represents the specific date for the pickup of the cancelled order item. This field is expected to follow a date format (e.g., YYYY-MM-DD).                                   |
| cancel\_order\_items.pickup\_date.hour\_range.start | string    | False    | Indicates the starting time of the pickup window, usually in the format of HH:MM (e.g., "09:00").                                                                             |
| cancel\_order\_items.pickup\_date.hour\_range.end   | string    | False    | Represents the ending time of the pickup window, usually in the format of HH:MM (e.g., "12:00").                                                                              |
| pickup\_address                                     | Integer   | False    | The ID of the address where the item should be picked up for return.                                                                                                          |
| fully\_refund\_as\_loyalty\_money                   | Boolean   | False    | Indicates whether the refund should be processed as loyalty money.                                                                                                            |

**Request Body**

```json
{
  "cancel_order_items": [
    {
      "description": "test",
      "reason": 1,
      "pickup_address": 3,
      "cancellation_type": "refund",
      "order_item": 1,
      "shipping_company": 1,
      "pickup_date": {
        "date": "2024-01-01",
        "hour_range": {
          "start": "09:00",
          "end": "12:00"
        }
      }
    }
  ]
}
```

**Example Request**

```py
import requests
import json

url = "https://{commerce_url}/users/orders/bulk_cancellation_requests/"

payload = json.dumps({
    "cancel_order_items": [
        {
            "order_item": 271,
            "reason": 3,
            "cancellation_type": "refund"
        }
    ]
})

headers = {
   'Content-Type': 'application/json',
   'Accept-Language': '<iso_language_code>',
   'Cookie': '<cookie-name>=<session_id>',
   'x-csrftoken': '<token>'
}

response = requests.post(url, headers=headers, data=payload)

print(response.text)
```

**Example Response (201 Created)**

```json
[
    {
        "id": 18,
        "cancellation_type": "refund",
        "status": {
            "value": "open",
            "label": "Open"
        },
        "easy_return": null,
        "created_date": "2023-01-16T19:39:35.592560Z",
        "modified_date": "2023-01-16T19:39:35.592575Z",
        "uuid": "62eeea09-2f48-4db8-9ca5-83168a8647e6",
        "description": null,
        "iban": null,
        "holder_name": null,
        "reason": 3,
        "order_item": 271
    }
]
```

### `GET` List User Order Cancellation Reasons

This endpoint retrieves a list of cancellation reasons associated with user orders. Cancellation reasons define why an order or item was canceled or returned, such as receiving the wrong product, changing one's mind, or other reasons. This can help in processing and managing cancellations more effectively.

**Path:** `/users/orders/cancellation_reasons/`

**Authentication Required:** Yes

**Headers:**

```
Accept-Language: <iso_language_code>
Cookie: <cookie-name>=<session_id>
```

**Example Request**

```py
import requests

url = "https://{commerce_url}/users/orders/cancellation_reasons/"

headers = {
  'Accept-Language: '<iso_language_code>',
  'Cookie': '<cookie-name>=<session_id>'
}

response = requests.get(url, headers=headers)

print(response.text)
```

**Example Response (200 OK)**

```json
{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 1,
            "cancellation_type": "cancel",
            "translations": {
          "en-us": {
              "subject": "I got the wrong product"
          }
      },
            "created_date": "2021-05-28T08:26:58.140000Z",
            "modified_date": "2021-05-28T08:27:01.826000Z",
            "uuid": "cfce77a6-14cb-489c-b81f-72d565529737",
            "subject": "Yanlış Ürün Aldım",
            "extra_information_needed": false,
            "order": 100,
            "is_active": true
        }
    ]
}
```

**Body Parameters**

| Property                   | Data Type | Description                                                                                         |
| -------------------------- | --------- | --------------------------------------------------------------------------------------------------- |
| cancellation\_type         | Enum      | The type of cancellation. Possible values are: “cancel” and “refund”.                               |
| translations               | Dict      | Translations for the subject of the cancellation reason in different languages.                     |
| uuid                       | String    | A unique identifier (UUID) for the cancellation reason.                                             |
| subject                    | String    | The subject of the cancellation reason, which describes why the order or product is being canceled. |
| extra\_information\_needed | Boolean   | Indicates if any additional information is needed from the user to process the cancellation         |
| order                      | Integer   | The ID of the order that this cancellation reason is associated with.                               |

### `GET` List User Order Cancellation Requests

This endpoint is used to retrieve a list of order cancellation requests for a user. Each cancellation request includes details like the reason for cancellation, the status of the request, and any related order details.

**Path:** `/users/orders/cancellation_requests/`

**Authentication Required:** Yes

**Headers:**

```
Accept-Language: <iso_language_code>
Cookie: <cookie-name>=<session_id>
```

**Example Request**

```py
import requests

url = "https://{commerce_url}/users/orders/cancellation_requests/"

headers = {
  'Accept-Language: '<iso_language_code>',
  'Cookie': '<cookie-name>=<session_id>'
}

response = requests.get(url, headers=headers)

print(response.text)
```

**Example Response (200 OK)**

```json
{
    "count": 6,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 6,
            "cancellation_type": "cancel",
            "status": {
                "value": "open",
                "label": "Open"
            },
            "easy_return": null,
            "created_date": "2019-11-12T11:07:36.721777Z",
            "modified_date": "2019-11-12T11:07:36.721806Z",
            "uuid": "1a2b3456-7cd4-49bb-9bf4-9495e9af845d",
            "description": "",
            "iban": null,
            "holder_name": null,
            "reason": 2,
            "order_item": 284
        },
        {
            "id": 5,
            "cancellation_type": "cancel",
            "status": {
                "value": "open",
                "label": "Open"
            },
            "easy_return": null,
            "created_date": "2019-11-12T11:05:32.022364Z",
            "modified_date": "2019-11-12T11:05:32.022422Z",
            "uuid": "1a2b3456-7cd4-49bb-9bf4-9495e9af845d",
            "description": "",
            "iban": null,
            "holder_name": null,
            "reason": 2,
            "order_item": 285
        },
    ]
}
```

### `POST` Create User Order Cancellation Request

This endpoint is used to create a new cancellation request for an order item. Users can request either a full cancellation of the order or a refund for the order item, with additional options for specifying shipping logistics, refund details, and the reason for the cancellation.

**Path:** `/users/orders/cancellation_requests/`

**Authentication Required:** Yes

**Headers:**

```
Content-Type: application/json
Accept-Language: <iso_language_code>
Cookie: <cookie-name>=<session_id>
x-csrftoken: <token>
```

**Body Parameters**

| Property                          | Data Type | Required | Description                                                                                                                                                                                        |
| --------------------------------- | --------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| cancellation\_type                | Enum      | True     | Indicates the type of cancellation: "cancel" for order cancellation, "refund" for refund request.                                                                                                  |
| reason                            | Integer   | True     | The ID of the cancellation reason.                                                                                                                                                                 |
| order\_item                       | Integer   | True     | The ID of the order item being canceled.                                                                                                                                                           |
| shipping\_company                 | Integer   | False    | The ID of the shipping company handling the return, if applicable.                                                                                                                                 |
| pickup\_address                   | Integer   | False    | The ID of the address where the item should be picked up for return.                                                                                                                               |
| pickup\_date                      | Dict      | False    | The scheduled date and time for pickup of the returned item. Includes `date` and `hour_range` (start and end times). { "date": "2024-01-01", "hour\_range": { "start": "09:00", "end": "12:00" } } |
| quantity                          | Integer   | False    | The number of items to be canceled (should not exceed the quantity ordered).                                                                                                                       |
| description                       | String    | False    | An optional description or message explaining the reason for cancellation.                                                                                                                         |
| iban                              | String    | False    | The IBAN number for the refund (if applicable).                                                                                                                                                    |
| holder\_name                      | String    | False    | The name of the account holder for refunding (if applicable).                                                                                                                                      |
| fully\_refund\_as\_loyalty\_money | Boolean   | False    | Indicates whether the refund should be processed as loyalty money.                                                                                                                                 |

**Request Body**

```json
{
    "order_item": 12345,
    "reason": 67890,
    "cancellation_type": "refund",
    "description": "Test description",
    "shipping_company": 1,
    "pickup_address": 101,
    "pickup_date": {
        "date": "2024-01-01",
        "hour_range": {
            "start": "09:00",
            "end": "12:00"
 	 }
     },
    "iban": "TR330006100519786457841326",
    "holder_name": "John Doe",
    "fully_refund_as_loyalty_money": true,
    "quantity": 2
}
```

**Example Request**

```py
import requests
import json

url = "https://{commerce_url}/users/orders/cancellation_requests/"

headers = {
  'Content-Type': 'application/json',
  'Accept-Language: '<iso_language_code>',
  'Cookie': '<cookie-name>=<session_id>',
  'x-csrftoken': '<token>'
}

payload = json.dumps({
    "order_item": 12345,
    "reason": 67890,
    "cancellation_type": "refund",
    "description": "Test description",
    "shipping_company": 1,
    "pickup_address": 101,
    "pickup_date": {
        "date": "2024-01-01",
        "hour_range": {
            "start": "09:00",
            "end": "12:00"
 	 }
     },
    "iban": "TR330006100519786457841326",
    "holder_name": "John Doe",
    "fully_refund_as_loyalty_money": true
})

response = requests.post(url, headers=headers, data=payload)
print(response.text)
```

**Example Response (200 OK)**

```json
{
    "status": {
        "value": "open",
        "label": "Open"
    },
    "modified_date": "2024-11-19T22:35:54.246633Z",
    "holder_name": "John Doe",
    "uuid": "8187c360-66da-4959-9f0b-9aa2ccac9001",
    "easy_return": {
        "status": {
            "value": "active",
            "label": "Active"
        },
        "code": "14223",
        "end_date": null,
        "tracking_url": "https://wwww.test.com",
        "tracking_number": "12352355",
        "shipping_company": {
            "value": "extension",
            "label": "Extension Cargo"
        },
        "pickup_date": {
            "date": "2024-01-01",
            "hour_range": {
                "start": "09:00",
                "end": "12:00"
            }
        },
        "start_date": "2024-11-19T22:35:54.246615Z"
    },
    "description": "test",
    "fully_refund_as_loyalty_money": true,
    "reason": 2,
    "iban": "test-iban",
    "cancellation_type": "refund",
    "created_date": "2024-11-19T22:35:54.246615Z",
    "order_item": 126,
    "id": 1,
    "quantity": 2
}
```

**Example Response (406 Not Acceptable)**

If the `pickup_address` is not provided:

```json
{
    "non_field_errors": "Pickup address is required.",
    "error_code": "cancellation_request_100_8"
}
```

**Example Response (400 Bad Request)**

If the `quantity` is provided and is greater than the available quantity of the order item

```json
{
    "quantity": "Quantity can not be greater than order item quantity."
}
```

### `GET` Retrieve User’s All Old Orders

This endpoint retrieves a list of previously placed orders for a user.

**Path:** `/users/old-orders/`

**Authentication Required:** Yes

**Headers:**

```
Accept-Language: <iso_language_code>
Content-Type: 'application/json'
Cookie: <cookie-name>=<session_id>
```

**Example Request**

```py
import requests

url = "https://{commerce_url}/users/old-orders/"

headers = {
    'Accept-Language': '<iso_language_code>',
    'Cookie': '<cookie-name>=<session_id>'
    'Content-Type': 'application/json',
}

response = requests.get(url, headers=headers)
print(response.json())
```

**Example Response (200 OK)**

```json
{
	"count": 1,
	"next": null,
	"previous": null,
	"results": [
    	{
        	"id": 5,
        	"currency": {
            	"value": "try",
            	"label": "TL"
        	},
        	"shipping_company": null,
        	"oldorderitem_set": [],
        	"number": "12345",
        	"user_email": "test_8@akinon.com",
        	"status": "pasive",
        	"created_date": "2023-01-16T19:35:12.330019Z",
        	"amount": "10.00",
        	"discount_amount": "8.00",
        	"payment_type": "credit card",
        	"bank": "garanti",
        	"installment_count": 3,
        	"tracking_number": "testtrack123",
        	"shipping_address": "dene adress",
        	"billing_address": "deneme address",
        	"extra_field": {},
        	"user": 1
    	}
	]
}
```

### `GET` Retrieve User’s Old Order

This endpoint retrieves the details of a specific previously placed order.

**Path:** `/users/old-orders/<pk>/`

**Authentication Required:** Yes

**Headers:**

```
Accept-Language: <iso_language_code>
Content-Type: application/json
Cookie: <cookie-name>=<session_id>
```

**Example Request**

```py
import requests

url = "https://{commerce_url}/users/old-orders/<pk>/"

headers = {
    'Accept-Language': '<iso_language_code>',
    'Cookie': '<cookie-name>=<session_id>'
    'Content-Type': 'application/json',
}

response = requests.get(url, headers=headers)
print(response.json())
```

**Example Response (200 OK)**

```json
{
	"id": 5,
	"currency": {
    	"value": "try",
    	"label": "TL"
	},
	"shipping_company": null,
	"oldorderitem_set": [],
	"number": "12345",
	"user_email": "test_8@akinon.com",
	"status": "pasive",
	"created_date": "2023-01-16T19:35:12.330019Z",
	"amount": "10.00",
	"discount_amount": "8.00",
	"payment_type": "credit card",
	"bank": "garanti",
	"installment_count": 3,
	"tracking_number": "testtrack123",
	"shipping_address": "dene adress",
	"billing_address": "deneme address",
	"extra_field": {},
	"user": 1
}
```

### `GET` Approve Trade-in

This endpoint confirms the approval of a trade offer for an item. The URL is sent via email, and clicking it confirms the trade.

**Path:** `/users/order_item/<pk>/tradein_approved/`

**Authentication Required:** Yes

**Headers:**

```
Accept-Language: <iso_language_code>
Cookie: '<cookie-name>=<session_id>'
```

**Example Request**

```py
import requests

url = "https://{commerce_url}/users/order_item/<pk>/tradein_approved/"

headers = {
    'Accept-Language': '<iso_language_code>',
    'Cookie': '<cookie-name>=<session_id>'
}

response = requests.get(url, headers=headers)
print(response.json())
```

**Example Response (200 OK)**

```json
Onaylama isleminiz gönderilmiştir.
```

### `GET` Reject Trade-in

This endpoint rejects a trade offer made for an item. The URL is sent to the user via email, and clicking the link confirms the rejection of the trade.

**Path:** `/users/order_item/<pk>/tradein_rejected/`

**Authentication Required:** No

**Headers:**

```
Accept-Language: <iso_language_code>
Cookie: '<cookie-name>=<session_id
```

**Example Request**

```py
import requests

url = "https://{commerce_url}/users/order_item/<pk>/tradein_rejected/"

headers = {
    'Accept-Language': '<iso_language_code>',
    'Cookie': '<cookie-name>=<session_id'
}

response = requests.get(url, headers=headers)
print(response.json())
```

**Example Response (200 OK)**

```json
Reddetme işleminiz gönderilmiştir.
```

### `POST` Direct Order Cancel

This endpoint directly cancels selected order items and sends the cancellation to Omnitron. It supports both authenticated and guest (anonymous) users.

**Path:** `/orders/{order_number}/cancel/`

**Authentication Required:** Optional — session cookie for authenticated users, `email` in request body for guest users.

**Headers (Authenticated User)**

```
Content-Type: application/json
Accept-Language: <iso_language_code>
Cookie: <cookie-name>=<session_id>
x-csrftoken: <token>
```

**Headers (Guest User)**

```
Content-Type: application/json
Accept-Language: <iso_language_code>
x-csrftoken: <token>
```

**Body Parameters**

| Property                                | Data Type | Required | Description                                                                                                    |
| --------------------------------------- | --------- | -------- | -------------------------------------------------------------------------------------------------------------- |
| email                                   | String    | No\*     | Required for guest users. Must match the email address used when placing the order.                            |
| cancel\_order\_items                    | Array     | True     | List of order items to cancel.                                                                                 |
| cancel\_order\_items.order\_item        | Integer   | True     | The ID of the order item to cancel.                                                                            |
| cancel\_order\_items.cancellation\_type | Enum      | True     | Type of cancellation. Possible values are `cancel` and `refund`.                                               |
| cancel\_order\_items.reason             | Integer   | True     | The ID of the cancellation reason.                                                                             |
| cancel\_order\_items.description        | String    | False    | An optional message explaining the reason for the cancellation.                                                |
| cancel\_order\_items.quantity           | Integer   | False    | Specifies the quantity to cancel. If not provided, all items are cancelled.                                    |
| cancel\_order\_items.iban               | String    | False    | IBAN number for refund processing (if applicable).                                                             |
| cancel\_order\_items.holder\_name       | String    | False    | Name of the account holder for refunding (if applicable).                                                      |
| cancel\_order\_items.shipping\_company  | Integer   | False    | The ID of the shipping company (if applicable).                                                                |
| cancel\_order\_items.pickup\_date       | Object    | False    | Scheduled pickup date and time. `{ "date": "2024-01-01", "hour_range": { "start": "09:00", "end": "12:00" } }` |
| pickup\_address                         | Integer   | False    | Address ID for product pickup (for refund requests with easy return). Not available for guest users.           |
| fully\_refund\_as\_loyalty\_money       | Boolean   | False    | If `true`, the refund will be processed as loyalty points.                                                     |

\* `email` is required only for guest users. If not provided and the user is not authenticated, the endpoint returns `401 Unauthorized`. Authenticated users do not need to provide it.

**How It Works:**

* **Authenticated users**: The order must belong to the logged-in user. Ownership is validated via session.
* **Guest users**: The `email` field must be provided and must match the email address used when placing the order.

If the direct cancellation to Omnitron succeeds, the endpoint returns `204 No Content` and the order item statuses are updated to `cancellation_waiting`. If the direct cancellation fails for any reason (e.g. Omnitron API error, validation rules), the system automatically creates local **CancellationRequest** records as a fallback and returns `200 OK`. If the fallback also fails (e.g. item already cancelled, item status not allowed), the endpoint returns `406 Not Acceptable`.

**Cancellable Order Statuses (Default):**

* `payment_waiting`
* `confirmation_waiting`
* `approved`

**Request Body (Authenticated User)**

```json
{
  "cancel_order_items": [
    {
      "order_item": 1,
      "cancellation_type": "cancel",
      "reason": 1,
      "description": "Changed my mind"
    }
  ]
}
```

**Request Body (Guest User)**

```json
{
  "email": "guest@example.com",
  "cancel_order_items": [
    {
      "order_item": 1,
      "cancellation_type": "cancel",
      "reason": 1,
      "description": "Changed my mind"
    }
  ]
}
```

**Example Request (Authenticated User)**

```py
import requests
import json

url = "https://{commerce_url}/orders/{order_number}/cancel/"

payload = json.dumps({
    "cancel_order_items": [
        {
            "order_item": 1,
            "cancellation_type": "cancel",
            "reason": 1,
            "description": "Changed my mind"
        }
    ]
})

headers = {
    'Content-Type': 'application/json',
    'Accept-Language': '<iso_language_code>',
    'Cookie': '<cookie-name>=<session_id>',
    'x-csrftoken': '<token>'
}

response = requests.post(url, headers=headers, data=payload)
print(response.text)
```

**Example Request (Guest User)**

```py
import requests
import json

url = "https://{commerce_url}/orders/{order_number}/cancel/"

payload = json.dumps({
    "email": "guest@example.com",
    "cancel_order_items": [
        {
            "order_item": 1,
            "cancellation_type": "cancel",
            "reason": 1,
            "description": "Changed my mind"
        }
    ]
})

headers = {
    'Content-Type': 'application/json',
    'Accept-Language': '<iso_language_code>',
    'x-csrftoken': '<token>'
}

response = requests.post(url, headers=headers, data=payload)
print(response.text)
```

**Example Response (204 No Content)**

Direct cancellation successful. No response body.

**Example Response (200 OK)**

Direct cancellation failed (e.g. Omnitron API error, validation rules). Local CancellationRequest records created as fallback.

```json
[
    {
        "id": 101,
        "uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
        "order_item": 1,
        "status": {
            "value": "open",
            "label": "Open"
        },
        "cancellation_type": "cancel",
        "reason": 1,
        "description": "Changed my mind",
        "created_date": "2024-06-15T10:30:00Z"
    }
]
```

**Example Response (400 Bad Request)**

Guest email does not match the order email:

```json
{"non_field_errors": ["The email address you entered does not match with order."]}
```

Guest order number not found (or belongs to a registered user):

```json
{"order": ["Object with number=\"1234567890\" does not exist."]}
```

Serializer validation error (e.g. invalid order item):

```json
{"cancel_order_items": [{"order_item": ["Invalid pk \"9999\" - object does not exist."]}]}
```

**Example Response (401 Unauthorized)**

No email provided and user is not authenticated:

```json
{"detail": "Authentication credentials were not provided."}
```

**Example Response (404 Not Found)**

Authenticated user: order not found or does not belong to the logged-in user:

```json
{"detail": "Not found."}
```

**Example Response (406 Not Acceptable)**

Item already cancelled:

```json
{"non_field_errors": "{item_name} order item already cancelled.", "error_code": "cancellation_request_100_3"}
```

Item status not allowed:

```json
{"non_field_errors": "{item_name} order item cannot be cancelled.", "error_code": "cancellation_request_100_6"}
```

Duplicate order items:

```json
{"non_field_errors": "Duplicate order items in request.", "error_code": "cancellation_request_100_7"}
```

IBAN required (refund with certain payment methods):

```json
{"non_field_errors": "IBAN number and Holder Name is required.", "error_code": "cancellation_request_100_5"}
```

Description required:

```json
{"non_field_errors": "For {item_name} order item, Description is required.", "error_code": "cancellation_request_100_4"}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://apidocs.akinon.com/commerce/users/user-orders-and-cancellations.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
