# Retrieve a gift

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


Retrieves a gift subscription. This API accepts the gift 'id' and returns the gift along with the subscription.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/gifts/__test__KyVnHhSBWTKhSAD__test__XF08jFEYWbAon3fSbc3IriS1N4UNhacdS \
     -u {site_api_key}:
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Gift.Retrieve("__test__KyVnHhSBWTKhSAD__test__XF08jFEYWbAon3fSbc3IriS1N4UNhacdS").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"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := giftAction.Retrieve("__test__KyVnHhSBWTKhSAD__test__XF08jFEYWbAon3fSbc3IriS1N4UNhacdS").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.GiftRetrieveRequest{
    Id : "__test__KyVnHhSBWTKhSAD__test__XF08jFEYWbAon3fSbc3IriS1N4UNhacdS",
}
  res, err := client.Gift.Retrieve(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;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = Gift.retrieve("__test__KyVnHhSBWTKhSAD__test__XF08jFEYWbAon3fSbc3IriS1N4UNhacdS").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.GiftRetrieveParams;
import com.chargebee.v4.models.gift.responses.GiftRetrieveResponse;
import com.chargebee.v4.models.subscription.Subscription;

public class GiftRetrieve {

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

        GiftRetrieveResponse response = client.gifts().retrieve("__test__KyVnHhSBWTKhSAD__test__XF08jFEYWbAon3fSbc3IriS1N4UNhacdS");

        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.retrieve("__test__KyVnHhSBWTKhSAD__test__XF08jFEYWbAon3fSbc3IriS1N4UNhacdS");

    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()->retrieve("__test__KyVnHhSBWTKhSAD__test__XF08jFEYWbAon3fSbc3IriS1N4UNhacdS");
$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.retrieve("__test__KyVnHhSBWTKhSAD__test__XF08jFEYWbAon3fSbc3IriS1N4UNhacdS")
gift = response.gift
subscription = response.subscription
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::Gift.retrieve("__test__KyVnHhSBWTKhSAD__test__XF08jFEYWbAon3fSbc3IriS1N4UNhacdS")

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__KyVnHhSBWTKfDA7"
    },
    "gift_timelines": [
      {
        "object": "gift_timeline",
        "occurred_at": 1517501491,
        "status": "scheduled"
      },
      {..}
    ],
    "gifter": {
      "customer_id": "gifter",
      "invoice_id": "__demo_inv__6",
      "object": "gifter",
      "signature": "John"
    },
    "id": "__test__KyVnHhSBWTKhSAD__test__XF08jFEYWbAon3fSbc3IriS1N4UNhacdS",
    "no_expiry": false,
    "object": "gift",
    "resource_version": 1517501491000,
    "scheduled_at": 1517501496,
    "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__KyVnHhSBWTKhSAD__test__XF08jFEYWbAon3fSbc3IriS1N4UNhacdS",
    "has_scheduled_changes": false,
    "id": "__test__KyVnHhSBWTKfDA7",
    "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

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

## Returns

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

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