---
type: api
title: Create an agent binary download source
description: Create a new agent binary download source.<br/><br/>[Required authorization] Route required privileges: fleet-settings-all.
url: https://www.elastic.co/elastic/docs-builder/docs/4843/api/doc/kibana/operation/operation-post-fleet-agent-download-sources
resource: https://www.elastic.co/elastic/docs-builder/docs/4843/api/doc/kibana/operation/operation-post-fleet-agent-download-sources
products:
  - Kibana
---

# Create an agent binary download source

Authentication: required

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

## Paths

- `POST` `/api/fleet/agent_download_sources`
- `POST` `/s/{space_id}/api/fleet/agent_download_sources`

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

Create a new agent binary download source.

## Required privileges

- Privileges: `fleet-settings-all`

## Header parameters

- `kbn-xsrf` (string) — required
  A required header to protect against CSRF attacks

## Request body

`application/json`

- `auth` (object) — optional — nullable
  - `api_key` (string) — optional
  - `headers` (object[] · max items: 100) — optional
    - `key` (string) — required
    - `value` (string) — required
  - `password` (string) — optional
  - `username` (string) — optional
- `host` (string · format: uri) — required
- `id` (string) — optional
- `is_default` (boolean · default: false) — optional
- `name` (string) — required
- `proxy_id` (string) — optional — nullable
  The ID of the proxy to use for this download source. See the proxies API for more information.
- `reserve_diskspace` (boolean) — optional
  If `true`, Elastic Agent reserves disk space equal to the size of the new agent package before an upgrade, so the upgrade fails early if there is not enough space. If not set, defaults to `true` on the agent side.
- `secrets` (object) — optional
  - `auth` (object) — optional
    - `api_key` (union anyOf) — optional
      - **{ id }**
        - `id` (string) — required
      - **string**
    - `password` (union anyOf) — optional
      - **{ id }**
        - `id` (string) — required
      - **string**
  - `ssl` (object) — optional
    - `key` (union anyOf) — optional
      - **{ id }**
        - `id` (string) — required
      - **string**
- `ssl` (object) — optional
  - `certificate` (string) — optional
  - `certificate_authorities` (string[] · max items: 10) — optional
  - `key` (string) — optional

## Responses

#### `200`

Successful response

`application/json`

- `item` (object)
  - `auth` (object) — nullable
    - `api_key` (string)
    - `headers` (object[] · max items: 100)
      - `key` (string)
      - `value` (string)
    - `password` (string)
    - `username` (string)
  - `host` (string · format: uri)
  - `id` (string)
  - `is_default` (boolean · default: false)
  - `is_preconfigured` (boolean)
  - `name` (string)
  - `proxy_id` (string) — nullable
    The ID of the proxy to use for this download source. See the proxies API for more information.
  - `reserve_diskspace` (boolean)
    If `true`, Elastic Agent reserves disk space equal to the size of the new agent package before an upgrade, so the upgrade fails early if there is not enough space. If not set, defaults to `true` on the agent side.
  - `secrets` (object)
    - `auth` (object)
      - `api_key` (union anyOf)
        - **{ id }**
          - `id` (string)
        - **string**
      - `password` (union anyOf)
        - **{ id }**
          - `id` (string)
        - **string**
    - `ssl` (object)
      - `key` (union anyOf)
        - **{ id }**
          - `id` (string)
        - **string**
  - `ssl` (object)
    - `certificate` (string)
    - `certificate_authorities` (string[] · max items: 10)
    - `key` (string)
#### `400`

Bad Request

`application/json`

- `attributes` (object)
- `error` (string)
- `errorType` (string)
- `message` (string)
- `statusCode` (number)
## Code examples

#### Console

```console
POST kbn:/api/fleet/agent_download_sources
{
  "host": "https://my-custom-host.example.com/downloads/",
  "is_default": false,
  "name": "My custom download source"
}
```

#### curl

```curl
curl -X POST "${KIBANA_URL}/api/fleet/agent_download_sources" \
  -H "kbn-xsrf: true" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "host": "https://my-custom-host.example.com/downloads/",
    "is_default": false,
    "name": "My custom download source"
  }'
```

## Response examples

#### Post download source

`application/json`

The created agent binary download source

```json
{
  "item": {
    "host": "https://my-custom-host.example.com/downloads/",
    "id": "download-source-id-2",
    "is_default": false,
    "name": "My custom download source"
  }
}
```

#### Generic error response

`application/json`

Example of a generic error response

```json
{
  "error": "Bad Request",
  "message": "An error message describing what went wrong",
  "statusCode": 400
}
```

