# Update a return

To [update](https://docs.commercelayer.io/core/updating-resources) an existing return, send a `PATCH` request to the `/api/returns/:id` endpoint, where `id` is the ID of the resource that you want to update.

Here below the list of all the possible arguments that you can pass with the request body.

## Request

**PATCH** <https://yourdomain.commercelayer.io/api/returns/:id>

### Arguments

| Body Parameter                         | Type      | Required |
| -------------------------------------- | --------- | -------- |
| **type**                               | `string`  | Required |
| **id**                                 | `string`  | Required |
| attributes.**\_request**               | `boolean` | Optional |
| attributes.**\_approve**               | `boolean` | Optional |
| attributes.**\_cancel**                | `boolean` | Optional |
| attributes.**\_ship**                  | `boolean` | Optional |
| attributes.**\_reject**                | `boolean` | Optional |
| attributes.**\_receive**               | `boolean` | Optional |
| attributes.**\_restock**               | `boolean` | Optional |
| attributes.**\_archive**               | `boolean` | Optional |
| attributes.**\_unarchive**             | `boolean` | Optional |
| attributes.**\_refund**                | `boolean` | Optional |
| attributes.**\_refund\_amount\_cents** | `integer` | Optional |
| attributes.**\_add\_tags**             | `string`  | Optional |
| attributes.**\_remove\_tags**          | `string`  | Optional |
| attributes.**reference**               | `string`  | Optional |
| attributes.**reference\_origin**       | `string`  | Optional |
| attributes.**metadata**                | `object`  | Optional |
| relationships.**stock\_location**      | `object`  | Optional |
| relationships.**reference\_capture**   | `object`  | Optional |
| relationships.**tags**                 | `array`   | Optional |

### Example

{% tabs %}
{% tab title="Request" %}
The following request updates the return identified by the ID "XAyRWNUzyN":

```shell
curl -g -X PATCH \
  'https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "returns",
    "id": "xYZkjABcde",
    "attributes": {
      "_request": true
    },
    "relationships": {
      "stock_location": {
        "data": {
          "type": "stock_locations",
          "id": "ABCRtyUpBa"
        }
      }
    }
  }
}'
```

{% endtab %}

{% tab title="Response" %}
On success, the API responds with a `200 OK` status code, returning the updated resource object:

```json
{
  "data": {
    "id": "XAyRWNUzyN",
    "type": "returns",
    "links": {
      "self": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN"
    },
    "attributes": {
      "number": "#1234/R/001",
      "status": "draft",
      "customer_email": "john@example.com",
      "skus_count": 2,
      "approved_at": "2018-01-01T12:00:00.000Z",
      "cancelled_at": "2018-01-01T12:00:00.000Z",
      "shipped_at": "2018-01-01T12:00:00.000Z",
      "rejected_at": "2018-01-01T12:00:00.000Z",
      "received_at": "2018-01-01T12:00:00.000Z",
      "refunded_at": "2018-01-01T12:00:00.000Z",
      "archived_at": "2018-01-01T12:00:00.000Z",
      "estimated_refund_amount_cents": 500,
      "estimated_refund_amount_float": 5.0,
      "formatted_estimated_refund_amount": "€5,00",
      "created_at": "2018-01-01T12:00:00.000Z",
      "updated_at": "2018-01-01T12:00:00.000Z",
      "reference": "ANY-EXTERNAL-REFEFERNCE",
      "reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
      "metadata": {
        "foo": "bar"
      }
    },
    "relationships": {
      "order": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/relationships/order",
          "related": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/order"
        }
      },
      "customer": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/relationships/customer",
          "related": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/customer"
        }
      },
      "stock_location": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/relationships/stock_location",
          "related": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/stock_location"
        }
      },
      "origin_address": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/relationships/origin_address",
          "related": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/origin_address"
        }
      },
      "destination_address": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/relationships/destination_address",
          "related": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/destination_address"
        }
      },
      "reference_capture": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/relationships/reference_capture",
          "related": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/reference_capture"
        }
      },
      "reference_refund": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/relationships/reference_refund",
          "related": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/reference_refund"
        }
      },
      "return_line_items": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/relationships/return_line_items",
          "related": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/return_line_items"
        }
      },
      "attachments": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/relationships/attachments",
          "related": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/attachments"
        }
      },
      "resource_errors": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/relationships/resource_errors",
          "related": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/resource_errors"
        }
      },
      "events": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/relationships/events",
          "related": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/events"
        }
      },
      "tags": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/relationships/tags",
          "related": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/tags"
        }
      },
      "versions": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/relationships/versions",
          "related": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/versions"
        }
      },
      "event_stores": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/relationships/event_stores",
          "related": "https://yourdomain.commercelayer.io/api/returns/XAyRWNUzyN/event_stores"
        }
      }
    },
    "meta": {
      "mode": "test",
      "organization_id": "xRRkjDFafe",
      "trace_id": "69abaa3545913c78132e5578bd26208d44aa9043647d78698fd0021f3958cd74"
    }
  }
}
```

{% endtab %}
{% endtabs %}
