---
type: api
title: Get a file
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/kibana/v8/operation/operation-endpointgetfileaction
resource: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/kibana/v8/operation/operation-endpointgetfileaction
products:
  - Kibana
---

# Get a file

Authentication: required

- Server: `https://{kibana_url}`

## Paths

- `POST` `/api/endpoint/action/get_file`
- `POST` `/s/{space_id}/api/endpoint/action/get_file`

#### Path parameters

- `space_id` (string) — optional
  An identifier for the space. If `space_id` is not provided in the URL, the default space is used. Refer to [Spaces](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.

## Description

Get a file from an endpoint.

## Request body

`application/json`

- `agent_type` (enum) — optional
  List of agent types to retrieve. Defaults to `endpoint`.
  Values: `endpoint`, `sentinel_one`, `crowdstrike`, `microsoft_defender_endpoint`
- `alert_ids` (string[] · format: nonempty · min items: 1) — optional
  A list of alerts ids.
- `case_ids` (string[] · min items: 1) — optional
  Case IDs to be updated (cannot contain empty strings)
- `comment` (string) — optional
  Optional comment
- `endpoint_ids` (string[] · min items: 1) — required
  List of endpoint IDs (cannot contain empty strings)
- `parameters` (object) — required
  Optional parameters object

## Response

OK

`application/json`

Type: `object`

## Code examples

#### Console

```console
POST kbn:/api/endpoint/action/get_file
{
  "comment": "Get my file",
  "endpoint_ids": [
    "ed518850-681a-4d60-bb98-e22640cae2a8"
  ],
  "parameters": {
    "path": "/usr/my-file.txt"
  }
}
```

#### curl

```curl
curl -X POST "${KIBANA_URL}/api/endpoint/action/get_file" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "comment": "Get my file",
    "endpoint_ids": [
      "ed518850-681a-4d60-bb98-e22640cae2a8"
    ],
    "parameters": {
      "path": "/usr/my-file.txt"
    }
  }'
```

## Response examples

#### 200

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "data": {
    "agents": [
      "ed518850-681a-4d60-bb98-e22640cae2a8"
    ],
    "agentState": {
      "ed518850-681a-4d60-bb98-e22640cae2a8": {
        "isCompleted": false,
        "wasSuccessful": false
      }
    },
    "agentType": "endpoint",
    "command": "get-file",
    "createdBy": "myuser",
    "hosts": {
      "ed518850-681a-4d60-bb98-e22640cae2a8": {
        "name": "gke-endpoint-gke-clu-endpoint-node-po-e1a3ab89-4c4r"
      }
    },
    "id": "27ba1b42-7cc6-4e53-86ce-675c876092b2",
    "isCompleted": false,
    "isExpired": false,
    "outputs": {},
    "parameters": {
      "path": "/usr/my-file.txt"
    },
    "startedAt": "2023-07-28T19:00:03.911Z",
    "status": "pending",
    "wasSuccessful": false
  }
}
```

