> 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.

# Export activity history

POST https://mandrillapp.com/api/1.4/exports/activity
Content-Type: application/json

Begins an export of your activity history. The activity will be exported to a zip archive containing a single file named activity.csv with message details and custom metadata fields.

Reference: https://mailchimp.com/developer/transactional/api/exports/activity

## Request

### Body (application/json)

This endpoint expects an ExportsActivityRequest.

- `key` (string, required) — A valid Mandrill API key
- `notify_email` (string, optional) — Optional email address to notify when the export job has finished
- `date_from` (string, optional) — Start date as a UTC string in YYYY-MM-DD HH:MM:SS format
- `date_to` (string, optional) — End date as a UTC string in YYYY-MM-DD HH:MM:SS format
- `tags` (list of string, optional) — Array of tag names to narrow the export to; will match messages that contain ANY of the tags
- `senders` (list of string, optional) — Array of sender email addresses to narrow the export to
- `states` (list of enum, optional) — Array of message states to narrow the export to; messages with ANY of the states will be included
  - Allowed values: `sent`, `rejected`, `bounced`, `soft-bounced`, `spam`, `unsub`
- `api_keys` (list of string, optional) — Array of API keys to narrow the export to; messages sent with ANY of the keys will be included

## Response

### 200

Success

- `any`

## Errors

### 401 Unauthorized Error

Invalid or missing API key.

- `status` (string, required) — Status of the response, typically "error"
- `code` (enum, required) — Numeric error code
  - Allowed values: `401`
- `name` (enum, required) — Machine-friendly error name
  - Allowed values: `Invalid_Key`
- `message` (string, required) — Human-readable error message

### 500 Internal Server Error

An unexpected internal server error occurred.

- `status` (string, required) — Status of the response, typically "error"
- `code` (integer, required) — Numeric error code
- `name` (string, required) — Machine-friendly error name
- `message` (string, required) — Human-readable error message

## Examples

**Request**

```json
{
  "key": "ONzNrsmbtNXoIKyfPmjnig",
  "notify_email": "admin@example.com",
  "date_from": "2013-01-01 12:53:01",
  "date_to": "2013-01-06 13:42:18",
  "tags": [
    "example-tag"
  ],
  "senders": [
    "test@example.com"
  ],
  "states": [
    "sent"
  ],
  "api_keys": [
    "ONzNrsmbtNXoIKyfPmjnig"
  ]
}
```

**Response**

```json
{
  "created_at": "2013-01-01 12:30:28",
  "finished_at": "2013-01-01 12:35:28",
  "id": "2013-01-01 12:20:28.13842",
  "result_url": "https://example.com/export-results.zip",
  "state": "waiting",
  "type": "reject"
}
```

**SDK Code**

```python
import requests

url = "https://mandrillapp.com/api/1.4/exports/activity"

payload = {
    "key": "ONzNrsmbtNXoIKyfPmjnig",
    "notify_email": "admin@example.com",
    "date_from": "2013-01-01 12:53:01",
    "date_to": "2013-01-06 13:42:18",
    "tags": ["example-tag"],
    "senders": ["test@example.com"],
    "states": ["sent"],
    "api_keys": ["ONzNrsmbtNXoIKyfPmjnig"]
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://mandrillapp.com/api/1.4/exports/activity';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"key":"ONzNrsmbtNXoIKyfPmjnig","notify_email":"admin@example.com","date_from":"2013-01-01 12:53:01","date_to":"2013-01-06 13:42:18","tags":["example-tag"],"senders":["test@example.com"],"states":["sent"],"api_keys":["ONzNrsmbtNXoIKyfPmjnig"]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://mandrillapp.com/api/1.4/exports/activity"

	payload := strings.NewReader("{\n  \"key\": \"ONzNrsmbtNXoIKyfPmjnig\",\n  \"notify_email\": \"admin@example.com\",\n  \"date_from\": \"2013-01-01 12:53:01\",\n  \"date_to\": \"2013-01-06 13:42:18\",\n  \"tags\": [\n    \"example-tag\"\n  ],\n  \"senders\": [\n    \"test@example.com\"\n  ],\n  \"states\": [\n    \"sent\"\n  ],\n  \"api_keys\": [\n    \"ONzNrsmbtNXoIKyfPmjnig\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://mandrillapp.com/api/1.4/exports/activity")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"key\": \"ONzNrsmbtNXoIKyfPmjnig\",\n  \"notify_email\": \"admin@example.com\",\n  \"date_from\": \"2013-01-01 12:53:01\",\n  \"date_to\": \"2013-01-06 13:42:18\",\n  \"tags\": [\n    \"example-tag\"\n  ],\n  \"senders\": [\n    \"test@example.com\"\n  ],\n  \"states\": [\n    \"sent\"\n  ],\n  \"api_keys\": [\n    \"ONzNrsmbtNXoIKyfPmjnig\"\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://mandrillapp.com/api/1.4/exports/activity")
  .header("Content-Type", "application/json")
  .body("{\n  \"key\": \"ONzNrsmbtNXoIKyfPmjnig\",\n  \"notify_email\": \"admin@example.com\",\n  \"date_from\": \"2013-01-01 12:53:01\",\n  \"date_to\": \"2013-01-06 13:42:18\",\n  \"tags\": [\n    \"example-tag\"\n  ],\n  \"senders\": [\n    \"test@example.com\"\n  ],\n  \"states\": [\n    \"sent\"\n  ],\n  \"api_keys\": [\n    \"ONzNrsmbtNXoIKyfPmjnig\"\n  ]\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://mandrillapp.com/api/1.4/exports/activity', [
  'body' => '{
  "key": "ONzNrsmbtNXoIKyfPmjnig",
  "notify_email": "admin@example.com",
  "date_from": "2013-01-01 12:53:01",
  "date_to": "2013-01-06 13:42:18",
  "tags": [
    "example-tag"
  ],
  "senders": [
    "test@example.com"
  ],
  "states": [
    "sent"
  ],
  "api_keys": [
    "ONzNrsmbtNXoIKyfPmjnig"
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://mandrillapp.com/api/1.4/exports/activity");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"key\": \"ONzNrsmbtNXoIKyfPmjnig\",\n  \"notify_email\": \"admin@example.com\",\n  \"date_from\": \"2013-01-01 12:53:01\",\n  \"date_to\": \"2013-01-06 13:42:18\",\n  \"tags\": [\n    \"example-tag\"\n  ],\n  \"senders\": [\n    \"test@example.com\"\n  ],\n  \"states\": [\n    \"sent\"\n  ],\n  \"api_keys\": [\n    \"ONzNrsmbtNXoIKyfPmjnig\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "key": "ONzNrsmbtNXoIKyfPmjnig",
  "notify_email": "admin@example.com",
  "date_from": "2013-01-01 12:53:01",
  "date_to": "2013-01-06 13:42:18",
  "tags": ["example-tag"],
  "senders": ["test@example.com"],
  "states": ["sent"],
  "api_keys": ["ONzNrsmbtNXoIKyfPmjnig"]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://mandrillapp.com/api/1.4/exports/activity")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```