# Download Log as CSV

Get a ZIP of CSV files from the API Call History of a Spark service. This is equivalent to the [API Call History](/navigation/api-call-history.md) functionality to *Download all API calls*, *Download as CSV*.

### Authorization

* `Bearer {token}` accessible from [Authorization - Bearer token](/spark-apis/authorization-bearer-token.md) or systematically via [Client Credentials](/identity-and-access-management/client-credentials.md).
  * The request headers should include a key for `Authorization` with the value `Bearer {token}`.
* API key created from [Authorization - API keys](/spark-apis/authorization-api-keys.md).\
  The [Authorization - API keys](/spark-apis/authorization-api-keys.md#api-key-groups) must contain [Manage users](/tenant-administration/manage-users.md#user-groups) that are also assigned to [Permissions - Features permissions](/spark-apis/authorization-api-keys/permissions-features-permissions.md) `Spark.DownloadCsvLog.json` or `Spark.AllEncompassingProxy.json`.
  * The request headers should include the keys `x-synthetic-key` and `x-tenant-name` with the values of the API key and tenant name respectively.

## `POST` log job

Returns: `status` response with  `job_id` of the requested job.

{% code overflow="wrap" %}

```shellscript
POST /{tenant}/api/v3/folders/{folder}/services/{service}/log/downloadcsv
```

{% endcode %}

### Path parameters

| Key          | Value                                                                                                                                                                                  |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `tenant` \*  | Tenant is part of your [Login and logout](/navigation/login-and-logout.md#log-in-to-spark) URL and also available in the  [Navigation menu](/navigation/navigation-menu.md#user-menu). |
| `folder` \*  | Folder associated with the API call.                                                                                                                                                   |
| `service` \* | Service associated with the API call.                                                                                                                                                  |

### Request body

`Content-Type: application/json`&#x20;

| Key                            | Value                                                                                                                                                                                                                                                                                                                                                                                                |
| ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `request_data.timezone_offset` | Number of hours to adjust the returned timestamps.                                                                                                                                                                                                                                                                                                                                                   |
| `request_data.start_date`      | <p>Timestamp for start log time filter. Use <a href="https://www.timestamp-converter.com/">Timestamp Converter</a> to convert dates to ISO 8601.<br>Example 1: <code>2022-10-30</code><br>Example 2: <code>2022-10-30T18:30:00.853Z</code></p>                                                                                                                                                       |
| `request_data.end_date`        | <p>Timestamp for end log time filter. Use <a href="https://www.timestamp-converter.com/">Timestamp Converter</a> to convert dates to ISO 8601.<br>Example 1: <code>2022-10-30</code><br>Example 2: <code>2022-10-30T18:30:00.853Z</code></p>                                                                                                                                                         |
| `request_data.call_ids`        | <p>Array containing <code>call\_id</code>s, or single element <code>correlation\_id</code>, or single element <code>source\_system</code> to filter.<br>Example 1: <code>\["329700e6-0850-40cf-b61e-310c2f756b73", fc01d941-bc29-4312-993a-c203913adcb8"]</code><br>Example 2: <code>\["correlation id for quotation"]</code><br><br></p><p>Example 3: <code>\["external source system "]</code></p> |
| `request_data.callpurpose`     | `call_purpose` to filter.                                                                                                                                                                                                                                                                                                                                                                            |
| `request_data.userName`        | <p>Username to filter.<br>Example: <code><myname@mydomain.com></code></p>                                                                                                                                                                                                                                                                                                                            |
| `request_data.has_warnings`    | <p>Boolean to filter calls with warnings.</p><p>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                       |
| `request_data.has_errors`      | <p>Boolean to filter calls with errors.<br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                            |
| `request_meta.version_id`      | <p><code>version\_id</code> to filter for a specific service version.<br>Example: <code>7c3a51a3-a0ae-41ec-b78a-5b8f75376b2f</code></p>                                                                                                                                                                                                                                                              |

### Sample request with API key

See [How to: Setup a feature permission](/spark-apis/authorization-api-keys/how-to-setup-a-feature-permission.md) for guidance in assigning the enable the [Authorization - API keys](/spark-apis/authorization-api-keys.md) to access [Permissions - Features permissions](/spark-apis/authorization-api-keys/permissions-features-permissions.md)`Spark.DownloadCsvLog.json`.

```sh
curl --location 'https://excel.myenvironmentname.coherent.global/mytenantname/api/v3/folders/myfoldername/services/myservicename/log/downloadcsv' \
--header 'Content-Type: application/json' \
--header 'x-tenant-name: mytenantname' \
--header 'x-synthetic-key: 5458626120e2' \
--data '{
    "request_data": {
        "start_date": "2023-11-11",
        "end_date": ""
    }
}'
```

### Sample response <a href="#api-response" id="api-response"></a>

`HTTP 200 OK` `Content-Type: application/json`

```json
{
    "status": null,
    "response_data": {
        "job_id": "ebcbf840-df82-472a-b9d4-073f14f4320b"
    },
    "response_meta": {
        "service_id": null,
        "version_id": null,
        "version": null,
        "process_time": 0,
        "call_id": null,
        "compiler_version": null,
        "source_hash": null,
        "engine_id": null,
        "correlation_id": null,
        "parameterset_version_id": null,
        "system": "SPARK",
        "request_timestamp": "2023-11-14T07:59:43.050Z"
    },
    "error": null
}
```

## `GET` log job status

Returns: `status` response and `download_url` to download the ZIP file.

{% code overflow="wrap" %}

```shellscript
GET /{tenant}/api/v3/folders/{folder}/services/{service}/log/downloadcsv/status/{jobId}
```

{% endcode %}

### Authorization

Follows from [#authorization](#authorization "mention") above.

### Path parameters

| Key            | Value                                                                                                                                                                                  |
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `{tenant}` \*  | Tenant is part of your [Login and logout](/navigation/login-and-logout.md#log-in-to-spark) URL and also available in the  [Navigation menu](/navigation/navigation-menu.md#user-menu). |
| `{folder}` \*  | Folder associated with the API call.                                                                                                                                                   |
| `{service}` \* | Service associated with the API call.                                                                                                                                                  |
| `{jobId}` \*   | `job_id` associated from [#post-log-job](#post-log-job "mention").                                                                                                                     |

### Sample request with API key

```sh
curl --location 'https://excel.myenvironmentname.coherent.global/mytenantname/api/v3/folders/myfoldername/services/myservicename/log/downloadcsv/status/ebcbf840-df82-472a-b9d4-073f14f4320b' \
--header 'x-tenant-name: <mytenantname>' \
--header 'x-synthetic-key: <myapikey>'
```

### Sample response

`HTTP 200 OK` `Content-Type: application/json`

```json
{
    "status": null,
    "response_data": {
        "progress": 100,        
        "download_url": "https://environment.coherent.global/SparkService_allRecords_2023_11_14_T_08_25_40.zip"
    },
    "response_meta": {
        "service_id": null,
        "version_id": null,
        "version": null,
        "process_time": 0,
        "call_id": null,
        "compiler_version": null,
        "source_hash": null,
        "engine_id": null,
        "correlation_id": null,
        "parameterset_version_id": null,
        "system": "SPARK",
        "request_timestamp": "2023-11-14T08:25:40.762Z"
    },
    "error": null
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.coherent.global/spark-apis/api-call-history-apis/download-log-as-csv.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
