> This page is for Mailchimp Marketing API.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://mailchimp.com/developer/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://mailchimp.com/developer/_mcp/server.

# Account exports

> Request your account\u2019s aggregate and granular reporting data for sent campaigns.

## The basics

You can download your Mailchimp account’s data with a single request, via either the Mailchimp app or the [Marketing API](/marketing/build/start-developing/send-your-first-api-request). The exported data—which will be provided as a .zip file—can include audiences, campaign content, template content, gallery assets, contact events, and both aggregate and granular reporting data for sent campaigns.

After an export is requested, it will build in the background for anywhere from a few minutes to (in rare cases) a few days. The eventual .zip can then be downloaded for up to 90 days.

In this doc we’ll explain how to make a request via the [Account Exports endpoint](/marketing/api/account-exports/create), including the options for choosing which data should be included. We’ll also run through the limitations of the export functionality, and the error messages you may encounter if something goes wrong.

If you’d prefer to export via the Mailchimp app, follow the steps detailed [here](https://mailchimp.com/help/export-back-up-data/). (Note that only [account Managers, Admins, or Owners](https://mailchimp.com/help/manage-user-levels-in-your-account/) can export via the app.

## Generate a new export

When requesting a new export via the Account Exports endpoint, you’ll need:

* Your [API key](/marketing/build/get-started/generate-your-api-key)
* The [category of data](/marketing/build/start-developing/account-exports/#api-parameters) (the stage) you want included in the export

Requests to the Account Exports endpoint should be structured like so:

**`cURL`**

```bash title="cURL"
curl -X POST \
  https://api.mailchimp.com/3.0/account-exports \
  --user "anystring:${apikey}"' \
  -d '{"include_stages":["audiences", "gallery_files"]}'
```

**`TypeScript`**

```typescript title="TypeScript"
import { MailchimpClient } from "@mailchimp/mailchimp-marketing";

const client = new MailchimpClient({
  token: "YOUR_API_KEY",
});

const response = await client.accountExports.create({
  include_stages: ["audiences", "gallery_files"],
});
console.log(response);
```

**`Python`**

```python title="Python"
from mailchimp_marketing import MailchimpClient
from mailchimp_marketing.core.api_error import ApiError

client = MailchimpClient(token="YOUR_API_KEY")

try:
  response = client.account_exports.create(
      include_stages=["audiences", "gallery_files"],
  )
  print(response)
except ApiError as error:
  print("Error: {}".format(error))
```

**`Go`**

```go title="Go"
import (
	"context"
	"fmt"

	sdk "github.com/mailchimp/mailchimp-marketing-go-sdk"
	mailchimp "github.com/mailchimp/mailchimp-marketing-go-sdk/client"
	"github.com/mailchimp/mailchimp-marketing-go-sdk/option"
)

client := mailchimp.NewMailchimpClient(
	option.WithToken("YOUR_API_KEY"),
)

response, err := client.AccountExports.Create(context.Background(), &sdk.CreateAccountExportsRequest{
	IncludeStages: []sdk.CreateAccountExportsRequestIncludeStagesItem{
		sdk.CreateAccountExportsRequestIncludeStagesItemAudiences,
		sdk.CreateAccountExportsRequestIncludeStagesItemGalleryFiles,
	},
})
fmt.Println(response)
```

**`Java`**

```java title="Java"
import com.mailchimp.marketing.MailchimpClient;
import com.mailchimp.marketing.resources.accountexports.types.CreateAccountExportsRequestIncludeStagesItem;
import com.mailchimp.marketing.resources.accountexports.requests.CreateAccountExportsRequest;

MailchimpClient client = MailchimpClient.builder()
    .token("YOUR_API_KEY")
    .build();

var response = client.accountExports().create(
    CreateAccountExportsRequest.builder()
        .includeStages(List.of(
            CreateAccountExportsRequestIncludeStagesItem.AUDIENCES,
            CreateAccountExportsRequestIncludeStagesItem.GALLERY_FILES))
        .build()
);
System.out.println(response);
```

**`C#`**

```csharp title="C#"
using Mailchimp.Marketing;

var client = new MailchimpClient("YOUR_API_KEY");

var response = await client.AccountExports.CreateAsync(
    new CreateAccountExportsRequest
    {
        IncludeStages = new List<CreateAccountExportsRequestIncludeStagesItem>
        {
            CreateAccountExportsRequestIncludeStagesItem.Audiences,
            CreateAccountExportsRequestIncludeStagesItem.GalleryFiles,
        },
    }
);
Console.WriteLine(response);
```

**`PHP`**

```php title="PHP"
require_once '/path/to/vendor/autoload.php';

use Mailchimp\MailchimpClient;
use Mailchimp\AccountExports\Requests\CreateAccountExportsRequest;

$client = new MailchimpClient('YOUR_API_KEY');

$response = $client->accountExports->create(new CreateAccountExportsRequest([
    'includeStages' => ["audiences", "gallery_files"],
]));
print_r($response);
```

**`Ruby`**

```ruby title="Ruby"
require 'mailchimp'

begin
  client = Mailchimp::Client.new(token: 'YOUR_API_KEY')

  response = client.account_exports.create(
    include_stages: ["audiences", "gallery_files"]
  )
  p response
rescue Mailchimp::Errors::ApiError => e
  puts "Error: #{e}"
end
```

**`Swift`**

```swift title="Swift"
import Mailchimp

let client = MailchimpClient(token: "YOUR_API_KEY")

let response = try await client.accountExports.create(
    request: Requests.CreateAccountExportsRequest(
        includeStages: [.audiences, .galleryFiles]
    )
)
print(response)
```

**`Rust`**

```rust title="Rust"
use mailchimp_marketing::prelude::*;

let config = ClientConfig {
    token: Some("YOUR_API_KEY".to_string()),
    ..Default::default()
};
let client = MailchimpClient::new(config).expect("Failed to build client");

let response = client
    .account_exports
    .create(
        &CreateAccountExportsRequest {
            include_stages: vec![
                CreateAccountExportsRequestIncludeStagesItem::Audiences,
                CreateAccountExportsRequestIncludeStagesItem::GalleryFiles,
            ],
            since_timestamp: None,
        },
        None,
    )
    .await;
println!("{:?}", response);
```

This example would generate an export containing all of a user’s contact data, as well as any image and content assets in their gallery.

## API parameters

The `include_stages` parameter tells the API which categories of information you’d like in your final download. Each request must include at least one stage, but you can request as many as you’d like.

These stages are:

| Stage           | Description                                                                                                                                                                                                                                                                                   |
| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `audiences`     | A folder with separate files for cleaned, subscribed, transactional (non-subscribed), and unsubscribed contacts.                                                                                                                                                                              |
| `campaigns`     | A CSV of all regular email campaigns located on the **Campaigns** page. This includes a `campaigns_content` folder with HTML and TXT files.                                                                                                                                                   |
| `events`        | A CSV of custom events passed into Mailchimp via the API. Includes timestamps, the event name, and the email address of the contact who created the event.                                                                                                                                    |
| `gallery_files` | A folder with all image and content assets stored in the **My Files** section of the content studio in your account. If you have a lot of assets stored in Mailchimp, this file will be large.                                                                                                |
| `reports`       | Different reporting data, split into three folders:  An `aggregate_activity` folder with overall data like opens, clicks, and unsubscribes. A `geo_data` folder with geolocation data for sent email campaigns.A `granular_activity` folder with open and click data for individual contacts. |
| `templates`     | A folder with HTML files of all your email templates.                                                                                                                                                                                                                                         |

### Time-limiting an export

If you’d like to limit your export to a specific date and time window, include the optional `since_timestamp` parameter. Passing an [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp will limit the exported data to content generated after that specific time and date.

Say you wanted to pull all of an account’s contact data and content assets that were added after April 4, 2000, at midnight UTC. Your code might look like:

**`cURL`**

```bash title="cURL"
curl -X POST \
  https://api.mailchimp.com/3.0/account-exports \
  --user "anystring:${apikey}"' \
  -d '{"include_stages":["audiences", "gallery_files"], "since_timestamp": 2000-04-04T00:00:01+00:00}'
```

**`TypeScript`**

```typescript title="TypeScript"
import { MailchimpClient } from "@mailchimp/mailchimp-marketing";

const client = new MailchimpClient({
  token: "YOUR_API_KEY",
});

const response = await client.accountExports.create({
  include_stages: ["audiences", "gallery_files"],
  since_timestamp: "2000-04-04T00:00:01+00:00",
});
console.log(response);
```

**`Python`**

```python title="Python"
from datetime import datetime, timezone
from mailchimp_marketing import MailchimpClient
from mailchimp_marketing.core.api_error import ApiError

client = MailchimpClient(token="YOUR_API_KEY")

try:
  response = client.account_exports.create(
      include_stages=["audiences", "gallery_files"],
      since_timestamp=datetime(2000, 4, 4, 0, 0, 1, tzinfo=timezone.utc),
  )
  print(response)
except ApiError as error:
  print("Error: {}".format(error))
```

**`Go`**

```go title="Go"
import (
	"context"
	"fmt"
	"time"

	sdk "github.com/mailchimp/mailchimp-marketing-go-sdk"
	mailchimp "github.com/mailchimp/mailchimp-marketing-go-sdk/client"
	"github.com/mailchimp/mailchimp-marketing-go-sdk/option"
)

client := mailchimp.NewMailchimpClient(
	option.WithToken("YOUR_API_KEY"),
)

sinceTimestamp := time.Date(2000, 4, 4, 0, 0, 1, 0, time.UTC)

response, err := client.AccountExports.Create(context.Background(), &sdk.CreateAccountExportsRequest{
	IncludeStages: []sdk.CreateAccountExportsRequestIncludeStagesItem{
		sdk.CreateAccountExportsRequestIncludeStagesItemAudiences,
		sdk.CreateAccountExportsRequestIncludeStagesItemGalleryFiles,
	},
	SinceTimestamp: &sinceTimestamp,
})
fmt.Println(response)
```

**`Java`**

```java title="Java"
import com.mailchimp.marketing.MailchimpClient;
import com.mailchimp.marketing.resources.accountexports.types.CreateAccountExportsRequestIncludeStagesItem;
import com.mailchimp.marketing.resources.accountexports.requests.CreateAccountExportsRequest;
import java.time.OffsetDateTime;

MailchimpClient client = MailchimpClient.builder()
    .token("YOUR_API_KEY")
    .build();

var response = client.accountExports().create(
    CreateAccountExportsRequest.builder()
        .includeStages(List.of(
            CreateAccountExportsRequestIncludeStagesItem.AUDIENCES,
            CreateAccountExportsRequestIncludeStagesItem.GALLERY_FILES))
        .sinceTimestamp(OffsetDateTime.parse("2000-04-04T00:00:01+00:00"))
        .build()
);
System.out.println(response);
```

**`C#`**

```csharp title="C#"
using Mailchimp.Marketing;

var client = new MailchimpClient("YOUR_API_KEY");

var response = await client.AccountExports.CreateAsync(
    new CreateAccountExportsRequest
    {
        IncludeStages = new List<CreateAccountExportsRequestIncludeStagesItem>
        {
            CreateAccountExportsRequestIncludeStagesItem.Audiences,
            CreateAccountExportsRequestIncludeStagesItem.GalleryFiles,
        },
        SinceTimestamp = DateTime.Parse("2000-04-04T00:00:01+00:00"),
    }
);
Console.WriteLine(response);
```

**`PHP`**

```php title="PHP"
require_once '/path/to/vendor/autoload.php';

use Mailchimp\MailchimpClient;
use Mailchimp\AccountExports\Requests\CreateAccountExportsRequest;

$client = new MailchimpClient('YOUR_API_KEY');

$response = $client->accountExports->create(new CreateAccountExportsRequest([
    'includeStages' => ["audiences", "gallery_files"],
    'sinceTimestamp' => new DateTime("2000-04-04T00:00:01+00:00"),
]));
print_r($response);
```

**`Ruby`**

```ruby title="Ruby"
require 'mailchimp'

begin
  client = Mailchimp::Client.new(token: 'YOUR_API_KEY')

  response = client.account_exports.create(
    include_stages: ["audiences", "gallery_files"],
    since_timestamp: "2000-04-04T00:00:01+00:00"
  )
  p response
rescue Mailchimp::Errors::ApiError => e
  puts "Error: #{e}"
end
```

**`Swift`**

```swift title="Swift"
import Mailchimp

let client = MailchimpClient(token: "YOUR_API_KEY")

let formatter = ISO8601DateFormatter()
let sinceTimestamp = formatter.date(from: "2000-04-04T00:00:01+00:00")

let response = try await client.accountExports.create(
    request: Requests.CreateAccountExportsRequest(
        includeStages: [.audiences, .galleryFiles],
        sinceTimestamp: sinceTimestamp
    )
)
print(response)
```

**`Rust`**

```rust title="Rust"
use mailchimp_marketing::prelude::*;

let config = ClientConfig {
    token: Some("YOUR_API_KEY".to_string()),
    ..Default::default()
};
let client = MailchimpClient::new(config).expect("Failed to build client");

let response = client
    .account_exports
    .create(
        &CreateAccountExportsRequest {
            include_stages: vec![
                CreateAccountExportsRequestIncludeStagesItem::Audiences,
                CreateAccountExportsRequestIncludeStagesItem::GalleryFiles,
            ],
            since_timestamp: Some("2000-04-04T00:00:01+00:00".parse().unwrap()),
        },
        None,
    )
    .await;
println!("{:?}", response);
```

## Downloading the data

To see and download all previous exports that have completed within the last 90 days, make a GET request to the [Account Exports endpoint](/marketing/api/account-exports/get). This will allow you to iterate through and download any previously completed exports using the `download_url` property in each item of the response. Each `download_url` links out to a file hosted by Google, our storage provider.

Each file URL is signed, and only accessible through the given URL. Please keep this URL as private as your API key: it provides direct and unauthorized user access to your account's data without any kind of user verification.

## Limits on exports

The same export limits apply for both the Mailchimp app and the API: you can only generate one export at a time, and only one export can be generated per 24-hour period.

Via the API, when these limits come into play you’ll get a `400` exception status code, accompanied by one of the following error messages:

* **Account Export in Progress**: Another export is already in progress. Wait until it’s done before trying to begin another one.
* **Too Many Account Exports**: The last export attempt was less than 24 hours ago. Each export’s `finished` field will be timestamped at completion, and 24 hours after that point another export may be requested.