﻿---
title: stack kb apm-agent-keys create-agent-key cli command
description: Create an APM agent key Behaviour flags: --dry-run — validate all inputs and exit without performing any action 
url: https://www.elastic.co/elastic/docs-builder/docs/4083/reference/elastic-cli/cli/stack/kb/apm-agent-keys/create-agent-key
applies_to:
  - Elastic Cloud Serverless: Preview
  - Elastic Stack: Preview
---

# stack kb apm-agent-keys create-agent-key cli command
<cli-modifiers>
</cli-modifiers>

```bash
elastic stack kb apm-agent-keys create-agent-key \
  --name <name> \
  --privileges <privileges> \
  [options]
```

Create an APM agent key
**Behaviour flags:**
`--dry-run` — validate all inputs and exit without performing any action

## Options

<definitions>
  <definition term="--name string required">
    The name of the APM agent key.
  </definition>
  <definition term="--privileges string[] required">
    The APM agent key privileges. It can take one or more of the following values:
    - `event:write`, which is required for ingesting APM agent events. * `config_agent:read`, which is required for APM agents to read agent configuration remotely.
    **Repeatable:** pass `--privileges` multiple times to supply more than one value
  </definition>
  <definition term="--input-file string">
    path to a JSON file to use as command input
  </definition>
  <definition term="--dry-run">
    validate all inputs and exit without performing any action (preview changes without applying them)
  </definition>
</definitions>


## Global Options

<definitions>
  <definition term="--json">
    output as JSON
  </definition>
</definitions>