Overview
Export as CSV
Export results as CSV
Some routes result can be exported as CSV for a better user experience. When that's the case, the client documentation will show a badge in the response section indicating that the route can return CSV.
This guide will show you how to use the API to export the results as CSV.
Request
To export the results as CSV, you need to add the Accept: text/csv header to your request. When application/json is also accepted, json will be returned.
Example of a request
curl https://api.textreveal.com/v3/entities/{entity_id}/esg/cases\
 --request GET\
 --header 'Authorization: Bearer <token>'\
 --header 'Accept: text/csv'Response
The response will contain the same fields as the json response's data field but in CSV format.
Example, if the json response is:
Example of a response - JSON
{
  "data": [
    {
      "id": "5eb7182b-9b55-4f7a-b3e1-49062ee7cef9",
      "categories": [
        "E"
      ],
      "entity_id": "00000000-0000-0000-0000-000000000000",
      "dashboard_url": "https://dashboards.textreveal.com/case/5eb7182b-9b55-4f7a-b3e1-49062ee7cef9",
      "last_activity": "2025-04-09T14:15:54.000Z",
      "score": 2,
      "start_date": "2025-04-09T14:15:54.000Z",
      "sub_categories": [
        "string"
      ],
      "summary": "string",
      "title": "string",
      "related_events_count": 8,
      "related_documents_count": 43
    }
  ],
  "size": 1,
  "has_next": true,
  "count": 1,
  "search_after": "string"
}The response will be:
Example of a response - CSV
id,categories,entity_id,dashboard_url,last_activity,score,start_date,sub_categories,summary,title,related_events_count,related_documents_count
5eb7182b-9b55-4f7a-b3e1-49062ee7cef9,E,00000000-0000-0000-0000-000000000000,https://dashboards.textreveal.com/case/5eb7182b-9b55-4f7a-b3e1-49062ee7cef9,2025-04-09T14:15:54.000Z,2,2025-04-09T14:15:54.000Z,string,string,string,8,43Errors
If the request is not valid, the error response will also be in CSV format.
Example:
Example of an error response - JSON
{
  "message": "Check the errors field for more details",
  "code": 400,
  "reason": "invalid",
  "errors": [
    {
      "field": "size",
      "reason": "too_big",
      "message": "The result window is too big. The maximum is 10000 current is 1000000 (`size * page`)"
    },
    {
      "field": "score",
      "reason": "custom",
      "message": "Value should be between 1 and 5"
    },
  ]
}The response will be:
Example of an error response - CSV
message,code,reason,errors.field,errors.reason,errors.message
Check the errors field for more details,400,invalid,size,too_big,The result window is too big. The maximum is 10000 current is 1000000 (`size * page`)
Check the errors field for more details,400,invalid,score,custom,Value should be between 1 and 5See the errors guide for more information.