# Update a purchase link

Source: https://developers.swell.is/backend-api/purchase-links/update-a-purchase-link

Update a purchase link.

## Arguments

- `id` (objectId, required): Unique identifier for the cart.
- `name` (objectId): Human-friendly name of the purchase link.
- `active` (boolean): The active status of the purchase link is automatically set to off and must be toggled on to activate, share, and use. Default: `False`.
- `items` (array of object): List of line items describing the products ordered.
  - `bundle_items` (array of object): List of items offered as a bundle. Defaults to `product.bundle_items`.
    - `id` (objectId): ID of the bundle item product.
    - `product_id` (objectId, required): ID of the bundle item product.
    - `product` (product): Expandable link to the bundle product.
    - `quantity` (int): Quantity of the bundle item being ordered. Defaults to 1. Default: `1`.
    - `shipment_weight` (float): Weight to be used in shipping calculation, if applicable.
    - `variant_id` (objectId): ID of the bundle item variant.
    - `variant` (variant): Expandable link to the bundle variant.
  - `description` (string): Description used for custom line items, when product is not defined.
  - `discounts` (array of object): List of discounts to apply to the item. Normally populated by applying a [coupon ](https://developers.swell.is/backend-api/coupons/the-coupon-model)or [promotions.](https://developers.swell.is/backend-api/promotions/the-promotion-model)
    - `id` (string, required): Unique identifier for the object. Should refer to one of the IDs in the cart `discounts` object.
    - `amount` (currency, required): Fixed discount amount.
  - `metadata` (object): Arbitrary item data, typically set in a checkout flow to store custom values. See [Storefront API](https://developers.swell.is/frontend-api/introduction) for details.
  - `options` (array of object): Item options matching one or more of `product.options`. When adding to the cart, specify either option `id` or `name` (case-insensitive) to identify the option.

    Gift card products have two special options that can be used when fulfilling gift cards by email. Use the option ID `send_email` and value as the recipient email address, and `send_note` as a custom message from the customer to the recipient sent by email.
    - `id` (string): Unique identifier for the object.
    - `name` (string): Name of the product option. Populated automatically when adding an option by ID.
    - `price` (currency): Additional price added onto the base price of the product.
    - `shipment_weight` (float): Additional shipping weight added onto the base weight of the product.
    - `value` (string): Name value of the product option. When adding to the cart, specify either the product option value `id` or `name` (case-insensitive) to identify the value.
    - `variant` (boolean): Indicates the option refers to a variant aspect.
  - `delivery` (enum): Method of delivery taken automatically from `product.delivery` Possible values: `shipment`, `giftcard`, `subscription`. Default: `{"$formula":"if(product_id, product.delivery)"}`.
  - `price` (currency): Price of the item. Override this value to set a custom price. Defaults to product price or sale price. Default: `{"$formula":"if(product_id, product.price)"}`.
  - `product_id` (objectId): ID of the item product.
  - `product` (product): Expandable link to the product, if applicable.
  - `quantity` (int): Quantity of the item being ordered. Defaults to 1. Default: `1`.
  - `shipment_weight` (float): Weight to be used in shipping calculation, if applicable.
  - `taxes` (array of object): List of tax rules to apply to the item. Normally populated by tax settings.
    - `id` (string, required): Unique identifier for the object. Should refer to one of the IDs in the cart `taxes` object.
    - `amount` (currency, required): Fixed tax amount.
  - `variant_id` (objectId): ID of the item variant, if applicable.
  - `variant` (variant): Expandable link to the variant, if applicable.
- `coupon_code` (string): Coupon code applied to the cart. See [coupons](https://developers.swell.is/backend-api/coupons) for details.
- `promotion_ids` (array of child_scalar): List of promotion IDs applied to the cart.

## Example request

`PUT /purchaselinks/:id`

**cURL**

```sh
$ curl https://api.swell.store/purchaselinks/DEEFRebs \
  -u store-id:secret-key \
  -d active=true \
  -X PUT
```

**Node**

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

await swell.put('/purchaselinks/{id}', {
  id: 'DEEFRebs',
  active: true
});
```

**PHP**

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

$swell->put('/purchaselinks/{id}', [
  'id' => 'DEEFRebs',
  'active' => true
]);
```

## Example response

```json
{
  "active": true,
  "name": "Purchase link example",
  "items": [
    {
      "product_id": "626034d4e7b741001968292d",
      "quantity": 1,
      "price": 5,
      "price_total": 5,
      "discount_total": 0,
      "discount_each": 0,
      "id": "62681502ea4c3f00138da5ea"
    }
  ],
  "currency": "USD",
  "sub_total": 5,
  "item_discount": 0,
  "discount_total": 0,
  "grand_total": 5,
  "date_created": "2022-04-26T15:51:30.324Z",
  "date_updated": "2022-04-26T15:52:33.949Z",
  "id": "DEEFRebs"
}
```
