---
type: api
title: Upload 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-endpointuploadaction
resource: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/kibana/v8/operation/operation-endpointuploadaction
products:
  - Kibana
---

# Upload a file

Authentication: required

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

## Paths

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

#### 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

Upload a file to an endpoint.

## Request body

`multipart/form-data`

- `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
- `file` (string · format: binary) — required
  The binary content of the file.

## Response

OK

`application/json`

Type: `object`

## Code examples

#### Console

```console
POST kbn:/api/endpoint/action/upload
```

#### curl

```curl
curl -X POST "${KIBANA_URL}/api/endpoint/action/upload" \
  -H "Authorization: ApiKey ${API_KEY}"
```

## 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": "upload",
    "createdBy": "elastic",
    "hosts": {
      "ed518850-681a-4d60-bb98-e22640cae2a8": {
        "name": "Host-5i6cuc8kdv"
      }
    },
    "id": "9ff6aebc-2cb6-481e-8869-9b30036c9731",
    "isCompleted": false,
    "isExpired": false,
    "outputs": {},
    "parameters": {
      "file_id": "10e4ce3d-4abb-4f93-a0cd-eaf63a489280",
      "file_name": "fix-malware.sh",
      "file_sha256": "a0bed94220193ba4895c0aa5b4e7e293381d15765cb164ddf7be5cdd010ae42a",
      "file_size": 69
    },
    "startedAt": "2023-07-03T15:07:22.837Z",
    "status": "pending",
    "wasSuccessful": false
  }
}
```

