Source: https://cli.nylas.com/docs/commands/audit-init

# nylas audit init

Initialize audit logging for the Nylas CLI. Creates the log directory, default configuration, and optionally enables logging immediately.

Written by [Qasim Muhammad](https://cli.nylas.com/authors/qasim-muhammad) Staff SRE

Published February 13, 2026

Updated June 21, 2026

## What does nylas audit init do?

The nylas audit init command sets up audit logging to record every CLI command execution with timestamps, arguments, and outcomes. Logs are stored locally in JSON or text format with configurable retention (default 90 days) and max file size (default 50 MB). Use audit logs to track AI agent activity, meet compliance requirements, or debug automation pipelines.

## Usage

```bash
nylas audit init [--path DIR] [--retention DAYS] [--enable]
```

## Flags

| Flag | Description |
| --- | --- |
| --json | Output as JSON |
| --no-color | Disable color output |
| --verbose(-v) | Enable verbose output |
| --config | Custom config file path |
| --help(-h) | Show help for the command |
| --limit | Limit results (most list commands) |
| --yes(-y) | Skip confirmations |
| --path | Custom directory for audit log storage |
| --retention | Log retention period in days (default: 90) |
| --max-size | Maximum log file size in MB (default: 50) |
| --format | Log format: json or text (default: json) |
| --enable | Enable logging immediately after initialization |
| --no-prompt | Skip interactive prompts (use defaults) |

## Examples

The nylas audit init command sets up audit logging to record every CLI command execution with timestamps, arguments, and outcomes.

### Interactive setup

```bash
nylas audit init
# Follow prompts to configure retention, format, and storage
```

### Non-interactive (CI/automation)

```bash
nylas audit init --retention 30 --format json --enable --no-prompt
```

### Custom storage path

```bash
nylas audit init --path /var/log/nylas-audit --max-size 100 --enable
```

## Example output

```text
✓ Audit logging initialized
  Log directory: ~/.config/nylas/audit
  Format: jsonl
  Retention: 90 days
  Max size: 50 MB
  Status: enabled
```

## Troubleshooting

### Permission denied when creating log directory

Ensure you have write permissions to the target path, or use --path to specify an accessible directory.

### Audit already initialized

Run `nylas audit config show` to see current settings. Use `nylas audit config set` to modify individual values.

## Related commands

[nylas audit config setSet an audit configuration value. Valid keys: retention_days, max_size_mb, rotate_daily, compress_old, log_request_id, log_api_details.](https://cli.nylas.com/docs/commands/audit-config-set)

[nylas audit config showShow the current audit configuration, including log path, retention, rotation, and compression settings.](https://cli.nylas.com/docs/commands/audit-config-show)

[nylas audit exportExport audit logs to JSON or CSV for compliance, analysis, or backup.](https://cli.nylas.com/docs/commands/audit-export)

[nylas audit logs clearClear all audit log entries. This is a destructive action — consider exporting logs first with `nylas audit export`.](https://cli.nylas.com/docs/commands/audit-logs-clear)

[nylas audit logs disableDisable audit logging. Stops recording CLI activity to the audit log file.](https://cli.nylas.com/docs/commands/audit-logs-disable)

[nylas audit logs enableEnable audit logging. Records all CLI activity to a local log file for compliance and debugging.](https://cli.nylas.com/docs/commands/audit-logs-enable)

## Recommended guides

[ai-catalog.json: Agent Discovery for Your SitePublish ai-catalog.json at /.well-known so AI agents can discover your MCP servers, APIs, and knowledge files. The draft Google-backed spec, schema, and a live example.](https://cli.nylas.com/guides/ai-catalog-json-agent-discovery)

[Thunderbird vs Nylas: GUI vs CLI emailThunderbird is a desktop GUI email client with OAuth and calendar built in. Compare it to a scriptable, headless CLI for servers, cron jobs, and AI agents.](https://cli.nylas.com/guides/nylas-vs-thunderbird)

[Pipedream vs Nylas for Email AutomationPipedream wires 3,000+ apps with event workflows and code steps. Nylas is a native email API with a CLI for agents and cron. Compare as a Pipedream alternative.](https://cli.nylas.com/guides/pipedream-vs-nylas)

[Detect Calendar Conflicts from the CLISpot double-booked meetings and overlapping events from the terminal. AI conflict detection and jq scripts catch calendar conflicts before they derail your day.](https://cli.nylas.com/guides/detect-calendar-conflicts-cli)

[Block Focus Time on Your Calendar (CLI)Context-switching costs 23 minutes of focus per interruption. Block focus time on Google Calendar from your terminal so meetings can't eat your deep-work slots.](https://cli.nylas.com/guides/block-focus-time-cli)

[Build a Strands Email AgentGive a Strands Agents SDK agent email access using the Nylas CLI as a @tool. One function reaches Gmail, Outlook, and 4 more providers — no OAuth code needed.](https://cli.nylas.com/guides/strands-email-agent)

Run `nylas audit init --help` for full help output.
