# Export attached items

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


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

[Eventually Consistent](/docs/api/read-consistency)

This API triggers export of attached item data. The exported zip file contains CSV files with attached item-related data.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/exports/attached_items \
     -u {site_api_key}:\
     -d "attached_item[type][is]"="MANDATORY"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Export.AttachedItems()
		.AttachedItemType().Is(AttachedItem.TypeEnum.Mandatory)
		.Request();

Export export = result.Export;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    "github.com/chargebee/chargebee-go/v3/filter"
    exportAction "github.com/chargebee/chargebee-go/v3/actions/export"
    "github.com/chargebee/chargebee-go/v3/models/export"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := exportAction.AttachedItems(&export.AttachedItemsRequestParams{
        AttachedItem : &export.AttachedItemsAttachedItemParams{
            Type : &filter.EnumFilter{
                Is : "mandatory",
            },
        },
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Export := res.Export
    }
}
```

#### 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.ExportAttachedItemsRequest{
    AttachedItem : &chargebee.ExportAttachedItemsAttachedItem{
        Type : &chargebee.EnumFilter{
            Is : "mandatory",
        },
    },
}
  res, err := client.Export.AttachedItems(req)
      if err != nil {
        fmt.Println(err)
    } else {
        Export := res.Export
    }
}
```

#### 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 = Export.attachedItems().attachedItemType().is(AttachedItem.Type.MANDATORY).request();

        Export export = result.export();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.export.Export;
import com.chargebee.v4.models.export.params.ExportAttachedItemsParams;
import com.chargebee.v4.models.export.responses.ExportAttachedItemsResponse;

public class ExportAttachedItems {

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

        ExportAttachedItemsParams.AttachedItemParams attachedItem =
            ExportAttachedItemsParams.AttachedItemParams.builder()
                .type()
                .is(ExportAttachedItemsParams.AttachedItemParams.Type.MANDATORY)
                .build();

        ExportAttachedItemsParams params = ExportAttachedItemsParams.builder()
            .attachedItem(attachedItem)
            .build();

        ExportAttachedItemsResponse response = client.exports().attachedItems(params);

        Export export = response.getExport();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

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

try {
    const result = await chargebee.export.attachedItems({
        attached_item: {
            type: {
                is: "mandatory"
            }
        }
    });

    console.log(result);
    const export_response = result.export;
} 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->export()->attachedItems([
    "attached_item" => [
        "type" => [
            "is" => "mandatory"
        ]
    ]
]);
$export = $result->export;
```

#### Python

```python
import chargebee
from chargebee import Chargebee, Filters

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Export.attached_items(
    cb_client.Export.AttachedItemsParams(
        attached_item=cb_client.Export.AttachedItemsAttachedItemParams(
            type=Filters.EnumFilter(IS=chargebee.AttachedItem.Type.MANDATORY)
        )
    )
)
export = response.export
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::Export.attached_items({
  "attached_item[type][is]" => "mandatory"
})

export = result.export
```

## Sample Response

```json
{
  "export": {
    "created_at": 1527791401,
    "id": "__test__8at0kS38wMW5Q",
    "mime_type": "zip",
    "object": "export",
    "operation_type": "Attached Items",
    "status": "in_process"
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/exports/attached_items

## Input Parameters

- `item_type` (optional, enumerated string)
  optional, enumerated string filter
  
  To filter based on the type of of the attached item. Possible values are : `addon` , `charge`. Possible values are : plan, addon, charge.
  
  **Supported operators :** is, is\_not, in, not\_in
  
  **Example →** _item\_type\[is\_not\] = "plan"_

- `attached_item` (optional, string)
  Parameters for attached\_item
  - `id` (optional, string)
    Filter attached items based on their id.
  - `item_id` (optional, string)
    Filter attached items based on the `item_id` of the item being attached.
  - `type` (optional, enumerated string)
    Filter attached items based on the `type` of attached item. Possible values are : `recommended` , `mandatory` , `optional` .
  - `charge_on_event` (optional, enumerated string)
    Indicates when the item is charged. This attribute only applies to charge-items.
  - `parent_item_id` (optional, string)
    The id of the plan-item to which the item is attached.
  - `updated_at` (optional, timestamp(UTC) in seconds)
    Filter attached items based on when the attached items were last updated.
    - `after` (optional, timestamp(UTC) in seconds)
    - `before` (optional, timestamp(UTC) in seconds)
    - `on` (optional, timestamp(UTC) in seconds)

## Returns

- `export` (Export object)
  Resource object representing export
