# Update a gift

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


[Idempotency Supported](/docs/api/idempotency)

Updates the attributes of a gift.

### Prerequisites & Constraints

-   The gift must be in the `scheduled` [status](/docs/api/gifts/gift-object#status).

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/gifts/__test__KyVnHhSBWTKnYAO__test__KdVPIxcd0gzgN1seidYQtm0ScuBcUgc3av/update_gift \
     -u {site_api_key}:\
     -d comment="Customer called and requested the change." \
     -d scheduled_at=1517587891
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Gift.UpdateGift("__test__KyVnHhSBWTKnYAO__test__KdVPIxcd0gzgN1seidYQtm0ScuBcUgc3av")
		.Comment("Customer called and requested the change.")
		.ScheduledAt(1517587891)
		.Request();

Gift gift = result.Gift;
Subscription subscription = result.Subscription;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    giftAction "github.com/chargebee/chargebee-go/v3/actions/gift"
    "github.com/chargebee/chargebee-go/v3/models/gift"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := giftAction.UpdateGift("__test__KyVnHhSBWTKnYAO__test__KdVPIxcd0gzgN1seidYQtm0ScuBcUgc3av", &gift.UpdateGiftRequestParams{
        Comment : "Customer called and requested the change.",
        ScheduledAt : chargebee.Int64(1517587891),
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Gift := res.Gift
        Subscription := res.Subscription
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.GiftUpdateGiftRequest{
    Comment : "Customer called and requested the change.",
    ScheduledAt : chargebee.Int64(1517587891),
}
  res, err := client.Gift.UpdateGift("__test__KyVnHhSBWTKnYAO__test__KdVPIxcd0gzgN1seidYQtm0ScuBcUgc3av", req)
      if err != nil {
        fmt.Println(err)
    } else {
        Gift := res.Gift
        Subscription := res.Subscription
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;
import java.sql.Timestamp;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = Gift.updateGift("__test__KyVnHhSBWTKnYAO__test__KdVPIxcd0gzgN1seidYQtm0ScuBcUgc3av")
            .comment("Customer called and requested the change.")
            .scheduledAt(new Timestamp(1517587891L * 1000))
            .request();

        Gift gift = result.gift();
        Subscription subscription = result.subscription();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.gift.Gift;
import com.chargebee.v4.models.gift.params.UpdateGiftParams;
import com.chargebee.v4.models.gift.responses.UpdateGiftResponse;
import com.chargebee.v4.models.subscription.Subscription;
import java.sql.Timestamp;

public class UpdateGift {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        UpdateGiftParams params = UpdateGiftParams.builder()
            .comment("Customer called and requested the change.")
            .scheduledAt(new Timestamp(1517587891L * 1000))
            .build();

        UpdateGiftResponse response = client
            .gifts()
            .updateGift("__test__KyVnHhSBWTKnYAO__test__KdVPIxcd0gzgN1seidYQtm0ScuBcUgc3av", params);

        Gift gift = response.getGift();
        Subscription subscription = response.getSubscription();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.gift.updateGift("__test__KyVnHhSBWTKnYAO__test__KdVPIxcd0gzgN1seidYQtm0ScuBcUgc3av", {
        comment: "Customer called and requested the change.",
        scheduled_at: 1517587891
    });

    console.log(result);
    const gift = result.gift;
    const subscription = result.subscription;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->gift()->updateGift("__test__KyVnHhSBWTKnYAO__test__KdVPIxcd0gzgN1seidYQtm0ScuBcUgc3av", [
    "comment" => "Customer called and requested the change.",
    "scheduled_at" => 1517587891
]);
$gift = $result->gift;
$subscription = $result->subscription;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Gift.update_gift("__test__KyVnHhSBWTKnYAO__test__KdVPIxcd0gzgN1seidYQtm0ScuBcUgc3av",
    cb_client.Gift.UpdateGiftParams(
        comment="Customer called and requested the change.",
        scheduled_at=1517587891
    )
)
gift = response.gift
subscription = response.subscription
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::Gift.update_gift("__test__KyVnHhSBWTKnYAO__test__KdVPIxcd0gzgN1seidYQtm0ScuBcUgc3av",{
  :comment => "Customer called and requested the change.",
  :scheduled_at => 1517587891
})

gift = result.gift
subscription = result.subscription
```

## Sample Response

```json
{
  "gift": {
    "auto_claim": false,
    "claim_expiry_date": 1525277496,
    "gift_receiver": {
      "customer_id": "receiver",
      "email": "james@user.com",
      "first_name": "James",
      "last_name": "William",
      "object": "gift_receiver",
      "subscription_id": "__test__KyVnHhSBWTKkwAI"
    },
    "gift_timelines": [
      {
        "object": "gift_timeline",
        "occurred_at": 1517501491,
        "status": "scheduled"
      },
      {..}
    ],
    "gifter": {
      "customer_id": "gifter",
      "invoice_id": "__demo_inv__7",
      "object": "gifter",
      "signature": "John"
    },
    "id": "__test__KyVnHhSBWTKnYAO__test__KdVPIxcd0gzgN1seidYQtm0ScuBcUgc3av",
    "no_expiry": false,
    "object": "gift",
    "resource_version": 1517501491000,
    "scheduled_at": 1517587891,
    "status": "scheduled",
    "updated_at": 1517501491
  },
  "subscription": {
    "billing_period": 1,
    "billing_period_unit": "month",
    "created_at": 1517501491,
    "currency_code": "USD",
    "customer_id": "receiver",
    "deleted": false,
    "due_invoices_count": 0,
    "gift_id": "__test__KyVnHhSBWTKnYAO__test__KdVPIxcd0gzgN1seidYQtm0ScuBcUgc3av",
    "has_scheduled_changes": false,
    "id": "__test__KyVnHhSBWTKkwAI",
    "next_billing_at": 1614615096,
    "object": "subscription",
    "plan_amount": 10000,
    "plan_free_quantity": 0,
    "plan_id": "GiftPlan$100",
    "plan_quantity": 1,
    "plan_unit_price": 10000,
    "remaining_billing_cycles": 1,
    "resource_version": 1517501491000,
    "start_date": 1612195896,
    "status": "future",
    "updated_at": 1517501491
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/gifts/{gift-id}/update_gift

## Input Parameters

- `scheduled_at` (optional, timestamp(UTC) in seconds)
  The new date/time at which the gift notification email is to be sent. The value must be greater than the current time. If [`no_expiry`](/docs/api/gifts/gift-object#no_expiry) is false, the value must also be less than [`claim_expiry_date`](/docs/api/gifts/gift-object#claim_expiry_date).

- `comment` (optional, string, max chars=250)
  An internal comment. The comments are not retrievable via API and are only available on request via [Chargebee Support](https://www.chargebee.com/docs/billing/2.0/kb/getting-started/how-to-contact-chargebees-support-team?utm_source=docs_api&utm_medium=content&utm_campaign=support).

- `gift_receiver` (optional, string)
  Parameters for gift\_receiver.
  - `email` (optional, string, max chars=70)
    The email address of the gift recipient. Must be a valid email address.
  - `first_name` (optional, string, max chars=150)
    First name of the recipient.
  - `last_name` (optional, string, max chars=150)
    Last name of the recipient.

## Returns

- `gift` (Gift object)
  Resource object representing gift

- `subscription` (Subscription object)
  Resource object representing subscription
