> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superagentes.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Exportar conversa usuario

## Exportar Conversa do Usuário

Este endpoint permite gerar uma visualização limpa e imprimível de uma conversa do usuário em formato HTML ou JSON.

### Casos de uso

* Gerar relatórios de conversas
* Criar backups de conversas
* Compartilhar conversas com outros usuários
* Análise de histórico de atendimento

### Parâmetros

| Parâmetro | Tipo   | Descrição                            |
| --------- | ------ | ------------------------------------ |
| id        | string | ID da conversa (obrigatório)         |
| format    | string | Formato de exportação (html ou json) |

<Card>
  <CardContent>
    Teste este endpoint diretamente do seu navegador.
  </CardContent>
</Card>

### Exemplos de código

<CodeGroup>
  ```javascript JavaScript theme={null}
  const exportUserConversation = async (conversationId, format = 'html') => {
    const response = await fetch(`https://dash.superagentes.ai/api/user-conversations/export/${conversationId}?format=${format}`, {
      method: 'GET',
      headers: {
        'Authorization': `Bearer ${seu_token_jwt}`,
        'Content-Type': 'application/json'
      }
    });
    
    if (format === 'html') {
      const html = await response.text();
      return html;
    } else {
      const data = await response.json();
      return data;
    }
  };
  ```

  ```python Python theme={null}
  import requests

  def export_user_conversation(conversation_id, format='html'):
      headers = {
          'Authorization': f'Bearer {seu_token_jwt}',
          'Content-Type': 'application/json'
      }
      
      params = {
          'format': format
      }
      
      response = requests.get(
          f'https://dash.superagentes.ai/api/user-conversations/export/{conversation_id}',
          headers=headers,
          params=params
      )
      
      if format == 'html':
          return response.text
      else:
          return response.json()
  ```

  ```curl cURL theme={null}
  curl --request GET \
    --url 'https://dash.superagentes.ai/api/user-conversations/export/conversation-id-1?format=json' \
    --header 'Authorization: Bearer seu_token_jwt' \
    --header 'Content-Type: application/json'
  ```
</CodeGroup>

### Exemplo de resposta

<ResponseExample>
  ```json theme={null}
  {
    "id": "conversation-id-1",
    "title": "Conversa com Cliente",
    "contactName": "Nome do Cliente",
    "phoneNumber": "+5511999999999",
    "channel": "whatsapp",
    "agentName": "Nome do Agente",
    "createdAt": "2024-01-01T00:00:00.000Z",
    "messages": [
      {
        "id": "message-id-1",
        "from": "agent",
        "text": "Olá, como posso ajudar?",
        "timestamp": "2024-01-01T00:00:00.000Z",
        "formattedTimestamp": "01/01/2024 00:00",
        "senderName": "Nome do Agente",
        "attachments": []
      }
    ]
  }
  ```
</ResponseExample>
