## Cancel allocation

### cURL

```bash
curl --request PUT \
  --url https://prod01.oms.fabric.inc/api/v2/allocation/cancel/{allocationIds} \
  --header 'Authorization: Bearer <token>' \
  --header 'x-site-context: <x-site-context>'
```

### Python

```python
import requests

url = "https://prod01.oms.fabric.inc/api/v2/allocation/cancel/{allocationIds}"

headers = {
    "x-site-context": "<x-site-context>",
    "Authorization": "Bearer <token>"
}

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

print(response.text)
```

### JavaScript (Fetch)

```javascript
const options = {
  method: 'PUT',
  headers: {'x-site-context': '<x-site-context>', Authorization: 'Bearer <token>'}
};

fetch('https://prod01.oms.fabric.inc/api/v2/allocation/cancel/{allocationIds}', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### PHP

```php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://prod01.oms.fabric.inc/api/v2/allocation/cancel/{allocationIds}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PUT",
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "x-site-context: <x-site-context>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

### Go

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

url := "https://prod01.oms.fabric.inc/api/v2/allocation/cancel/{allocationIds}"

req, _ := http.NewRequest("PUT", url, nil)

req.Header.Add("x-site-context", "<x-site-context>")
	req.Header.Add("Authorization", "Bearer <token>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))
}
```

### Unirest (Java)

```java
HttpResponse<String> response = Unirest.put("https://prod01.oms.fabric.inc/api/v2/allocation/cancel/{allocationIds}")
  .header("x-site-context", "<x-site-context>")
  .header("Authorization", "Bearer <token>")
  .asString();
```

### Ruby

```ruby
require 'uri'
require 'net/http'

url = URI("https://prod01.oms.fabric.inc/api/v2/allocation/cancel/{allocationIds}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["x-site-context"] = '<x-site-context>'
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

### Response Codes
- **200**: Success
- **404**: Not Found
- **500**: Internal Server Error

### Example Successful Response
```json
[
  {
    "allocationId": "62ff5c0bec0aed3c86202c32",
    "parentAllocationId": "62ff5c0bec0aed3c86202c32",
    "locationNum": "1234B",
    "items": [
      {
        "itemId": "100064",
        "sku": "123k4h123k",
        "quantity": 3,
        "allocationLineNumber": 3,
        "orderLineId": "134fqfaa532qrf",
        "orderId": "123k4h123k",
        "orderDate": "2022-08-01T18:03:28.483971941Z",
        "estimatedDeliveryDate": "2022-08-01T18:03:28.483971941Z",
        "parentAllocationLineNumber": 3,
        "reallocationRequestId": "123k4h123k",
        "shippedQuantity": 1,
        "scratchQuantity": 1,
        "scratchedReasonCode": "Scratched during shipment",
        "reshipReasonCode": "Reshipping during shipment",
        "reallocationReasonCode": "Reallocating due to unavailability of location number",
        "channelId": "12",
        "segment": null,
        "vendorId": "56",
        "title": "Demo",
        "weight": 5.5,
        "cost": 500.2,
        "price": 50.2,
        "itemStatus": "ALLOCATED",
        "attributes": {},
        "uom": "KG"
      }
    ],
    "version": 2,
    "allocationRequestId": "62ff5c0bec0aed3c86202c32",
    "allocationNum": "xxyyzz12345",
    "sentToPPSDate": "2022-08-01T18:03:28.483971941Z",
    "allocationDate": "2022-08-01T18:03:28.483971941Z",
    "updatedAt": "2022-08-01T20:03:28.483971941Z",
    "type": "ALLOCATED",
    "previousAllocationLocationNum": 410,
    "poNumber": "1125",
    "itemsType": "WEB_SHIP",
    "orderSubType": "BORDERFREE",
    "vendorId": "56",
    "shipDate": null,
    "shipType": "SHIP_TO_ADDRESS",
    "shipMethod": "Overnight Delivery",
    "shipToId": "98ff5c0bec0aed3c86202c32",
    "statusCode": "PENDING_PICK",
    "locationType": "1234B",
    "shipToAddress": {},
    "recipient": [
      {
        "name": {
          "first": "John",
          "middle": "Middle",
          "last": "Doe"
        },
        "email": "demo@xyz.inc",
        "phone": {
          "number": "55555555555",
          "type": "MOBILE"
        },
        "pickupType": "Primary"
      }
    ],
    "auditLogs": [
      {
        "lineItemId": "4",
        "auditId": "62272e917b12209e68751d94",
        "auditType": "UPDATE",
        "employeeId": "62272e917b12209e68751d94",
        "auditTimestamp": "2022-05-12T09:24:54.804Z",
        "source": "POS",
        "reasonCode": "POS",
        "subReasonCode": "POS",
        "policyCode": "POS",
        "note": "Note",
        "lineItemNumber": 1,
        "sku": "F5F",
        "quantity": 1,
        "amount": 2.4,
        "paymentToken": {
          "token": "pi_34tr6787rt",
          "paymentType": "VISA"
        },
        "success": true,
        "paymentResponse": {},
        "updatedFields": [
          {
            "fieldName": "UOM",
            "fieldOriginalValue": "PK"
          }
        ],
        "attributes": {}
      }
    ]
  }
]
```

### Error Response

```json
{
  "message": "Allocation with AllocationRequestId is not found"
}
```

```json
{
  "message": "Internal Server Error"
}
```

### Authorizations

Authorization

- **Type**:  `string`
- **Location**:  Header
- **Required**: Yes
- Bearer authentication header of the form `Bearer <token>`, where `<token>` is your auth token.

### Headers

- **x-site-context**: string (required)  
  The `x-site-context` header is a JSON object that contains information about the source you wish to pull from. The mandatory `account` is the 24 character identifier found in Copilot. The `channel` (Sales channel ID), `stage` (environment name), and `date` attributes can be used to further narrow the scope of your data source.

Example:
  ```json
  {"date": "2023-01-01T00:00:00.000Z", "channel": 12, "account": "1234abcd5678efgh9ijklmno","stage":"production"}
  ```

### Path Parameters

- **allocationIds**: string[] (required)

### Response
- **200**: application/json  
  Cancel Allocation

- **allocationId**: string (required)  
  Unique ID for an allocation document.

Example:  
  ```json
  "62ff5c0bec0aed3c86202c32"
  ```
