# Update a return

Source: https://developers.swell.is/backend-api/returns/update-a-return

Update an existing return using the ID that was obtained when it was created.

## Arguments

- `id` (objectId, required): Unique identifier for the return.
- `order_id` (objectId, required): ID of the order this return was created for.
- `canceled` (boolean): Indicates the return was canceled.
- `carrier` (string): ID of a 3rd party carrier offering the service, if applicable.
- `carrier_name` (string): Name of a 3rd party carrier offering the service, if applicable.
- `credit_tax` (currency, auto): Total amount of taxes credited to the order for the returned items.
- `credit_total` (currency, auto): Total amount of additional credit applied to the order.
- `currency` (string): Three-letter ISO currency code in uppercase. Defaults to the store's base currency.
- `date_estimated` (date): Date the expected return shipment is meant to arrive at a warehouse, if applicable.
- `destination` (object): The intended return destination.
  - `location` (string): ID of the intended return destination, if applicable. Default: `"default"`.
- `extra_credit` (currency): Arbitrary amount to apply to the order as compensation for their inconvenience.
- `item_quantity_receivable` (int, auto): Total quantity of line items that can still be received in a return shipment.
- `item_quantity_received` (int, auto): Total quantity of line items that have been received in a return shipment.
- `item_quantity_restockable` (int, auto): Total quantity of line items that can still be restocked to product inventory.
- `item_quantity_restocked` (int, auto): Total quantity of line items that have been restocked to product inventory.
- `notes` (string): Internal admin notes, not visible to the customer.
- `notifications` (Notification): Expandable list of notifications sent on behalf of the products returned.
- `number` (string, auto): Unique incremental return number, assigned automatically.
- `order` (Order): Expandable link to the order.
- `origin` (object): The customer's location of origin for the return shipment.
  - `address1` (string): Origin address line 1: street address/PO box/company name.
  - `address2` (string): Origin address line 2: apartment/suite/unit/building.
  - `city` (string): Origin city/district/suburb/town/village.
  - `country` (string): Two-letter ISO country code.
  - `name` (string): Origin customer name.
  - `phone` (string): Origin phone number.
  - `state` (string): Origin state/county/province/region.
  - `zip` (string): Origin zip/postal code.
- `reason_code` (string): Code indicating the reason for the return.
- `received` (boolean, auto): Indicates that all items have been received in a return shipment. Default: `false`.
- `restock_fee` (currency): Amount to charge the customer for re-stocking the returned items.
- `service` (string): ID of a shipping service as configured in shipment settings.
- `service_name` (string): Name of the return shipping service.
- `shipment_tax` (currency, auto): Amount to apply to the order as a credit as compensation for the original shipping tax.
- `shipment_total` (currency): Amount to apply to the order as a credit as compensation for the original shipping price.
- `tracking_code` (string): Tracking code used to identify the return shipment, if applicable.

## Example request

`PUT /returns/:id`

**cURL**

```bash
$ curl https://api.swell.store/returns/60f199509111e70000000078 \
  -u store-id:secret-key \
  -d tracking_code=T192000000XYZ \
  -d service=fedex_ground \
  -X PUT
```

**Node**

```javascript
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');

await swell.put('/returns/{id}', {
  id: '60f199509111e70000000078',
  tracking_code: 'T192000000XYZ',
  service: 'fedex_ground'
});
```

**PHP**

```php
<?php $swell = new \Swell\Client('store-id', 'secret-key');

$swell->put('/returns/{id}', [
  'id' => '60f199509111e70000000078',
  'tracking_code' => 'T192000000XYZ',
  'service' => 'fedex_ground'
]);
```

## Example response

```json
{
  "id": "60f199509111e70000000078",
  "items": [
    {
      "id": "5ca537326a0ec32a521139dd",
      "order_item_id": "5a9ea7ba3f95740a914267f2",
      "product_id": "5cad15bc9b14d1990724663b",
      "quantity": 2,
      "quantity_received": 0,
      "quantity_receivable": 2,
      "quantity_restocked": 0,
      "quantity_restockable": 2
    }
  ],
  "order_id": "60f199509111e7000000007d",
  "currency": "USD",
  "date_created": "2021-07-16T14:36:00.399Z",
  "date_updated": "2021-07-16T14:36:00.399Z",
  "origin": {
    "name": "Jon Snow",
    "address1": "1 Main Street",
    "city": "Brooklyn",
    "state": "NY",
    "zip": 11201,
    "country": "US",
    "phone": "(555) 555-5555"
  },
  "received": false,
  "service": "fedex_ground",
  "tracking_code": "T192000000XYZ"
}
```
