---
updatedAt: 2026-05-27T08:00:07.000Z
agentTools:
  projectIndex: https://docs.d-id.com/llms.txt
---

# Create chat logs

Create a chat log export for `agent_id` containing all of the Agent's chats.

Use the `export_id` in the GET chat logs endpoint to get the result of the create chat logs request (zipped JSON files).

(The chat log export will be deleted from the database after 7 days from the export creation date)

Creates a chat log export for the specified `agent_id`, including all chats for that Agent.\
Use the returned `export_id` with the Get a Chats Export by ID endpoint to download the exported chat logs as zipped JSON files.\
Exports are automatically deleted after 7 days.

# OpenAPI definition

```json
{
  "openapi": "3.0.3",
  "info": {
    "title": "Realtime Endpoints",
    "version": "0.1"
  },
  "servers": [
    {
      "url": "https://api.d-id.com/"
    }
  ],
  "paths": {
    "/agents/chats/exports": {
      "post": {
        "operationId": "Create chat logs",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "export_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "export_id"
                  ],
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "RangeError",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonError"
                },
                "examples": {
                  "Example 1": {
                    "value": {
                      "kind": "BadRequestError",
                      "description": "Agent not found"
                    }
                  },
                  "Example 2": {
                    "value": {
                      "kind": "BadRequestError",
                      "description": "Invalid date format"
                    }
                  },
                  "Example 3": {
                    "value": {
                      "kind": "RangeError",
                      "description": "Invalid date range"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AuthorizationError",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonError"
                },
                "examples": {
                  "Example 1": {
                    "value": {
                      "kind": "AuthorizationError",
                      "description": "user unauthenticated"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "InternalServerError",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonError"
                },
                "examples": {
                  "Example 1": {
                    "value": {
                      "kind": "InternalServerError",
                      "description": "failed to create export"
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Create a chat log export for `agent_id` containing all of the Agent's chats.\n\nUse the `export_id` in the GET chat logs endpoint to get the result of the create chat logs request (zipped JSON files).\n\n(The chat log export will be deleted from the database after 7 days from the export creation date)",
        "summary": "Create chat logs",
        "tags": [
          "Chats Export"
        ],
        "security": [
          {
            "basic": []
          },
          {
            "bearer": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExportDto"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "JsonError": {
        "properties": {
          "kind": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "details": {},
          "internal": {
            "type": "string"
          }
        },
        "required": [
          "kind",
          "description"
        ],
        "type": "object",
        "additionalProperties": false
      },
      "ExportParams": {
        "properties": {
          "agent_id": {
            "type": "string",
            "description": "The id of the agent that the export will run for"
          },
          "from": {
            "type": "string",
            "description": "The start of the time range for the export.  If not provided, the export will start from the beginning of the agent's data",
            "example": "2024-05-15T12:00:00Z"
          },
          "to": {
            "type": "string",
            "description": "The end of the time range for the export. If not provided, the export will run until the current time",
            "example": "2024-05-15T12:00:00Z"
          },
          "persistent_chats": {
            "type": "boolean",
            "description": "Determines if the export should fetch persistent chats. Defaults to true."
          }
        },
        "required": [
          "agent_id"
        ],
        "type": "object",
        "additionalProperties": false
      },
      "ExportDto": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ExportParams"
          },
          {
            "properties": {
              "token": {
                "type": "string",
                "description": "Pagination - used to continue the creation of the chat log using this same endpoint"
              }
            },
            "type": "object"
          }
        ]
      }
    },
    "securitySchemes": {
      "basic": {
        "type": "http",
        "scheme": "basic"
      }
    }
  },
  "x-readme": {
    "samples-languages": [
      "curl"
    ]
  }
}
```