## Update allocation attributes

### cURL

```
curl --request POST \
  --url https://api.fabric.inc/v3/allocations/{allocationId}/actions/update-attributes \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'x-fabric-channel-id: <x-fabric-channel-id>' \
  --header 'x-fabric-tenant-id: <x-fabric-tenant-id>' \
  --data '\
{
  "attributes": {
    "attr1": "value"
  },
  "keysToRemove": [\
    "<string>"\
  ]
}
'```

### Python

```
import requests

url = "https://api.fabric.inc/v3/allocations/{allocationId}/actions/update-attributes"

payload = {
    "attributes": { "attr1": "value" },
    "keysToRemove": ["<string>"]
}
headers = {
    "x-fabric-tenant-id": "<x-fabric-tenant-id>",
    "x-fabric-channel-id": "<x-fabric-channel-id>",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.text)
```

### JavaScript (Fetch)

```
const options = {
  method: 'POST',
  headers: {
    'x-fabric-tenant-id': '<x-fabric-tenant-id>',
    'x-fabric-channel-id': '<x-fabric-channel-id>',
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({attributes: {attr1: 'value'}, keysToRemove: ['<string>']})
};

fetch('https://api.fabric.inc/v3/allocations/{allocationId}/actions/update-attributes', 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://api.fabric.inc/v3/allocations/{allocationId}/actions/update-attributes",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'attributes' => [
        'attr1' => 'value'
    ],
    'keysToRemove' => [
        '<string>'
    ]
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json",
    "x-fabric-channel-id: <x-fabric-channel-id>",
    "x-fabric-tenant-id: <x-fabric-tenant-id>"
  ],
]);

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

curl_close($curl);

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

### Go

```
package main

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

func main() {

url := "https://api.fabric.inc/v3/allocations/{allocationId}/actions/update-attributes"

payload := strings.NewReader("{\n  \"attributes\": {\n    \"attr1\": \"value\"\n  },\n  \"keysToRemove\": [\n    \"<string>\"\n  ]\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("x-fabric-tenant-id", "<x-fabric-tenant-id>")
	req.Header.Add("x-fabric-channel-id", "<x-fabric-channel-id>")
	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

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

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

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

### Responses
#### Success Response (200)
```
{
  "allocationId": "62ff5c0bec0aed3c86202c32",
  "allocationRequestId": "62ff5c0bec0aed3c86202c32",
  "createdAt": "2022-08-01T18:03:28.483971941Z",
  "locationNumber": "1234B",
  "version": 2,
  "allocationNumber": 13000004,
  "allocationExternalId": "123k4h123k",
  "auditLogs": [...],
  "currency": "USD",
  "items": [...],
  "itemsType": "WEB_SHIP",
  "locationType": "DC",
  "notifiedToPPSAt": "2022-08-01T18:03:28.483971941Z",
  "orderSubType": "ANDROID",
  "parentAllocationId": "62ff5c0bec0aed3c86202c32",
  "recipients": [...],
  "shipToAddress": {...},
  "shipFromAddress": {...},
  "shipToId": "98ff5c0bec0aed3c86202c32",
  "shipmentMethod": "Parcel Post Delivery",
  "shipmentType": "SHIP_TO_ADDRESS",
  "shippedAt": "2022-08-01T20:03:28.483971941Z",
  "statusCode": "ALLOCATED",
  "type": "ALLOCATED",
  "updatedAt": "2022-08-01T20:03:28.483971941Z"
}
```

#### Error Responses
##### Client Error (400)
```
{
  "type": "CLIENT_ERROR",
  "errorCode": "SERVICE-4003",
  "message": "Mandatory or invalid request parameters",
  "errors": [...],
  "context": {...}
}
```

##### Unauthorized Error (401)
```
{
  "type": "CLIENT_ERROR",
  "errorCode": "SERVICE-4001",
  "message": "Unauthorized request",
  "errors": [],
  "context": {...}
}
```

##### Allocation Not Found (404)
```
{
  "type": "CLIENT_ERROR",
  "message": "Allocation not found",
  "errorCode": "SERVICE-4040",
  "errors": [],
  "context": {...}
}
```

##### Internal Server Error (500)
```
{
  "type": "SERVER_ERROR",
  "errorCode": "SERVICE-5000",
  "message": "Internal server error",
  "errors": [],
  "context": {...}
}
```
