# Export customers

> 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 customer data. The exported zip file contains CSV files with customer-related data.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/exports/customers \
     -u {site_api_key}:\
     -d "customer[first_name][is_not]"="John" \
     -d "customer[last_name][is_not]"="Doe"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Export.Customers()
		.CustomerFirstName().IsNot("John")
		.CustomerLastName().IsNot("Doe")
		.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.Customers(&export.CustomersRequestParams{
        Customer : &export.CustomersCustomerParams{
            FirstName : &filter.StringFilter{
                IsNot : "John",
            },
            LastName : &filter.StringFilter{
                IsNot : "Doe",
            },
        },
    }).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.ExportCustomersRequest{
    Customer : &chargebee.ExportCustomersCustomer{
        FirstName : &chargebee.StringFilter{
            IsNot : "John",
        },
        LastName : &chargebee.StringFilter{
            IsNot : "Doe",
        },
    },
}
  res, err := client.Export.Customers(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.customers().customerFirstName().isNot("John").customerLastName().isNot("Doe").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.ExportCustomersParams;
import com.chargebee.v4.models.export.responses.ExportCustomersResponse;

public class ExportCustomers {

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

        ExportCustomersParams.CustomerParams customer =
            ExportCustomersParams.CustomerParams.builder()
                .firstName()
                .isNot("John")
                .lastName()
                .isNot("Doe")
                .build();

        ExportCustomersParams params = ExportCustomersParams.builder()
            .customer(customer)
            .build();

        ExportCustomersResponse response = client.exports().customers(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.customers({
        customer: {
            first_name: {
                is_not: "John"
            },
            last_name: {
                is_not: "Doe"
            }
        }
    });

    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()->customers([
    "customer" => [
        "first_name" => [
            "is_not" => "John"
        ],
        "last_name" => [
            "is_not" => "Doe"
        ]
    ]
]);
$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.customers(
    cb_client.Export.CustomersParams(
        customer=cb_client.Export.CustomersCustomerParams(
            first_name=Filters.StringFilter(IS_NOT="John"),
            last_name=Filters.StringFilter(IS_NOT="Doe")
        )
    )
)
export = response.export
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::Export.customers({
  "customer[first_name][is_not]" => "John",
  "customer[last_name][is_not]" => "Doe"
})

export = result.export
```

## Sample Response

```json
{
  "export": {
    "created_at": 1527791400,
    "id": "__test__KyVnHhSBWTC8J8p",
    "mime_type": "zip",
    "object": "export",
    "operation_type": "Customers",
    "status": "in_process"
  }
}
```

## URL Format

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

## Input Parameters

- `export_type` (optional, enumerated string, default=data)
  Determines the format of the data. Returns the export type based on the selected value.
  Possible enum values:
    - `data`
      Provides the full set of data for the customers in multiple `.csv` files.
    - `import_friendly_data`
      Provides a `.csv` file whose columns match the [`customer`](/docs/api/customers/customer-object) schema. This file format can be readily imported through the UI by using [Bulk Operations](https://www.chargebee.com/docs/bulk-operations.html).

- `business_entity_id` (optional, string)
  optional, string filter
  
  The unique ID of the [business entity](/docs/api/getting-started) of this subscription. This is always the same as the [business entity](/docs/api/subscriptions/subscription-object#customer_id) of the customer.
  
  **Supported operators :** is, is\_not, starts\_with
  
  **Example →** _business\_entity\_id\[is\] = "business\_entity\_id"_

- `customer` (optional, string)
  Parameters for customer
  - `id` (optional, string)
    Identifier of the customer.
  - `first_name` (optional, string)
    First name of the customer
  - `last_name` (optional, string)
    Last name of the customer
  - `email` (optional, string)
    Email of the customer. Configured email notifications will be sent to this email.
  - `company` (optional, string)
    Company name of the customer.
  - `phone` (optional, string)
    Phone number of the customer
  - `auto_collection` (optional, enumerated string)
    Whether payments needs to be collected automatically for this customer
  - `taxability` (optional, enumerated string)
    Specifies if the customer is liable for tax
  - `offline_payment_method` (optional, enumerated string)
    The preferred offline payment method for the customer.
  - `auto_close_invoices` (optional, enumerated string)
    Override for this customer, the [site-level setting](https://www.chargebee.com/docs/billing/2.0/usage-based-billing/metered_billing#configuring-metered-billing) for auto-closing invoices. Only applicable when auto-closing invoices has been enabled for the site. This attribute is also available at the [subscription level](/docs/api/subscriptions/subscription-object#auto_close_invoices) which takes precedence.
  - `channel` (optional, enumerated string)
    The subscription channel this object originated from and is maintained in.
  - `created_at` (optional, timestamp(UTC) in seconds)
    Timestamp indicating when this customer resource is created.
    - `after` (optional, timestamp(UTC) in seconds)
    - `before` (optional, timestamp(UTC) in seconds)
    - `on` (optional, timestamp(UTC) in seconds)
  - `updated_at` (optional, timestamp(UTC) in seconds)
    To filter based on `updated_at`. This attribute will be present only if the resource has been updated after 2016-09-28. It is advisable when using this filter, to pass the `sort_by` input parameter as `updated_at` for a faster response.
    - `after` (optional, timestamp(UTC) in seconds)
    - `before` (optional, timestamp(UTC) in seconds)
    - `on` (optional, timestamp(UTC) in seconds)

- `relationship` (optional, string)
  Parameters for relationship
  - `parent_id` (optional, string)
    Immediate parent with whom we will link our new customer(child)
  - `payment_owner_id` (optional, string)
    Parent who is going to pay
  - `invoice_owner_id` (optional, string)
    Parent who is going to handle invoices

## Returns

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