# Chat Exports

## Get Recent Chat Exports

> Export chat history for all contacts with recent activity within the specified number of hours.\
> Supports JSON (default) and plain text file formats.\
> \
> Text format returns a downloadable .txt file attachment with all conversations combined.\
> JSON format returns structured data with per-contact message exports.<br>

```json
{"openapi":"3.1.0","info":{"title":"DM Champ API","version":"1.0.0"},"servers":[{"url":"https://api.dmchamp.com/v1","description":"Production API Server"}],"security":[{"ApiKeyAuth":[]},{"UserIdAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"query","name":"apiKey","description":"Your DM Champ API key. Obtain from Settings → API Keys."},"UserIdAuth":{"type":"apiKey","in":"query","name":"userId","description":"Your DM Champ User ID. Alternative to apiKey authentication. Cannot be used for agency-only endpoints."}},"parameters":{"ApiKeyParam":{"name":"apiKey","in":"query","description":"API key for authentication. At least one of apiKey or userId is required for protected endpoints.","required":false,"schema":{"type":"string"}},"UserIdParam":{"name":"userId","in":"query","description":"User ID for authentication. Alternative to apiKey. At least one of apiKey or userId is required for protected endpoints.","required":false,"schema":{"type":"string"}}},"schemas":{"ChatExport":{"type":"object","description":"Chat export data for a single contact","properties":{"contactId":{"type":"string","description":"Contact identifier"},"contactName":{"type":"string","description":"Contact full name"},"phoneNumber":{"type":"string","description":"Contact phone number"},"email":{"type":"string","description":"Contact email address"},"messageCount":{"type":"integer","description":"Number of messages in the export"},"chatExport":{"type":"string","description":"Full chat export as formatted text"}}}}},"paths":{"/chat-exports/recent":{"get":{"summary":"Get Recent Chat Exports","description":"Export chat history for all contacts with recent activity within the specified number of hours.\nSupports JSON (default) and plain text file formats.\n\nText format returns a downloadable .txt file attachment with all conversations combined.\nJSON format returns structured data with per-contact message exports.\n","tags":["Chat Exports"],"parameters":[{"$ref":"#/components/parameters/ApiKeyParam"},{"$ref":"#/components/parameters/UserIdParam"},{"name":"hours","in":"query","required":true,"schema":{"type":"integer","minimum":1},"description":"Number of hours to look back for recent contact activity"},{"name":"format","in":"query","required":false,"schema":{"type":"string","enum":["json","txt"],"default":"json"},"description":"Output format. Use 'txt' to download a plain text file attachment."},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","default":50,"minimum":1},"description":"Maximum number of contacts to export"},{"name":"filter","in":"query","required":false,"schema":{"type":"string","enum":["all","media","tool_use","text"],"default":"all"},"description":"Filter messages by type:\n- all: Include all messages\n- media: Only messages with media attachments\n- tool_use: Only tool use / AI action messages\n- text: Only plain text messages (no media, no tool use)\n"}],"responses":{"200":{"description":"Chat exports retrieved successfully.\nWhen format=txt, returns a downloadable text file.\nWhen format=json (default), returns structured JSON.\n","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"hours_ago":{"type":"integer","description":"Number of hours looked back"},"total_contacts":{"type":"integer","description":"Number of contacts in the export"},"exports":{"type":"array","items":{"$ref":"#/components/schemas/ChatExport"}}}}}}},"text/plain":{"schema":{"type":"string","description":"Combined chat export as plain text file (when format=txt)"}}}},"400":{"description":"Missing or invalid hours parameter","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"error_code":{"type":"integer"},"error":{"type":"string"}}}}}},"401":{"description":"Authentication required or invalid credentials","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"error_code":{"type":"integer"},"error":{"type":"string"}}}}}}}}}}}
```
