# Global Options & Configuration

## Global options

These options are available on every command:

| Option                  | Description                                                                                               |
| ----------------------- | --------------------------------------------------------------------------------------------------------- |
| `--config <path>`       | Config file path                                                                                          |
| `--api-key <key>`       | Override API key                                                                                          |
| `--endpoint <url>`      | Override API endpoint                                                                                     |
| `--app <name>`          | Override default application                                                                              |
| `--env <name>`          | Override default environment                                                                              |
| `-o, --output <format>` | Output format: `table` (default), `json`, `yaml`, `plain`, `markdown`, `rendered`, `vertical`, `template` |
| `--no-color`            | Disable colored output                                                                                    |
| `-v, --verbose`         | Verbose output                                                                                            |
| `-q, --quiet`           | Minimal output                                                                                            |
| `--profile <name>`      | Use a specific profile                                                                                    |
| `--terse`               | Compact format with truncation                                                                            |
| `--full`                | Full text without truncation                                                                              |
| `--raw`                 | Show raw API response without summarizing or transforming                                                 |

## Debugging API traffic

These flags write to **stderr** (so they don't pollute piped stdout) and respect `--no-color` and the `NO_COLOR` env var. Authorization headers and known sensitive body fields (`key`, `password`, `token`, `secret`, `access_token`, `refresh_token`, `api_key`) are redacted by default.

| Option            | Description                                                                                                           |
| ----------------- | --------------------------------------------------------------------------------------------------------------------- |
| `--show-request`  | Print outgoing HTTP requests as a readable HTTP-style block.                                                          |
| `--show-response` | Print HTTP responses (success and error) as an HTTP-style block.                                                      |
| `--curl`          | Print outgoing requests as curl commands for inspection. `Authorization` is redacted unless you add `--show-secrets`. |
| `--show-secrets`  | Don't redact `Authorization` / `Set-Cookie` / sensitive body fields. Use with care.                                   |
| `--headers-only`  | Omit request and response bodies from `--show-request` / `--show-response` / `--curl` output.                         |
| `--status-only`   | Print only the response status line, e.g. `← 200 OK (175ms)`. Implies `--show-response`.                              |

```bash
abs experiments get 1816 --show-request --show-response
abs experiments list --curl                            # inspectable curl (Authorization redacted)
abs experiments update 123 --field "Hypothesis=Updated hypothesis" --show-request
```

`--curl` output redacts the `Authorization` header and known sensitive body fields by default. That makes it safer to share, but other headers, query parameters, paths or body fields can still contain credentials or user data, so check the output before sharing it. Redacted output won't authenticate if you paste it into a shell. Add `--show-secrets` to get a replayable, authenticated command; this prints your API key in plain text, so don't paste that output into tickets, chat or logs. `--headers-only` strips request bodies, so combining it with `--curl` won't give a complete, replayable command for requests that send a body (`POST`, `PUT`, `PATCH`).

`--show-request` is the fastest way to see the exact payload shape the CLI sends for a given command — useful when integrating directly against the REST API and you want to confirm a field's wire format, such as [custom field values](https://docs.absmartly.com/docs/APIs-and-SDKs/CLI-Documentation/experiments-and-feature-flags.md#custom-field-options).

## Configuration file

Configuration is stored in `~/.config/absmartly/config.yaml` as YAML. API keys are stored securely in your OS keychain via [keytar](https://github.com/atom/node-keytar).

```bash
# View current configuration
abs config list

# Get/set individual values
abs config get output
abs config set output json
abs config unset output

# Manage profiles
abs config profiles list
abs config profiles use readonly
abs config profiles delete old-profile
```

### Configuration file format

```yaml
default-profile: default
analytics-opt-out: false
output: table
profiles:
  default:
    api:
      endpoint: https://your-instance.absmartly.com/v1
    expctld:
      endpoint: https://ctl.absmartly.io/v1
    application: my-app
    environment: production
  readonly:
    api:
      endpoint: https://your-instance.absmartly.com/v1
    expctld:
      endpoint: https://ctl.absmartly.io/v1
    environment: production
```

### Environment variables

| Variable                 | Description                                       |
| ------------------------ | ------------------------------------------------- |
| `ABSMARTLY_API_KEY`      | API key (overrides keychain and credentials file) |
| `ABSMARTLY_API_ENDPOINT` | API endpoint URL (overrides profile config)       |

See [Authentication](https://docs.absmartly.com/docs/APIs-and-SDKs/CLI-Documentation/authentication.md) for the full credential resolution order and OAuth/API key login flows.

## Date formats

All `--from`, `--to`, `--since`, `--created-after`, `--started-before`, and other date/timestamp options across the CLI accept the same formats:

| Format              | Example                                 |
| ------------------- | --------------------------------------- |
| Relative (short)    | `7d`, `2w`, `1mo`, `24h`, `30m`, `1y`   |
| Relative (with ago) | `7d ago`, `2 weeks ago`, `3 months ago` |
| Keywords            | `today`, `yesterday`, `now`             |
| ISO 8601 date       | `2024-01-01`                            |
| ISO 8601 datetime   | `2024-01-01T00:00:00Z`                  |
| Epoch milliseconds  | `1704067200000`                         |

Relative units: `m` (minutes), `h` (hours), `d` (days), `w` (weeks), `mo` (months), `y` (years). Case-insensitive.

Commands using date formats:

* `abs experiments list --created-after`, `--created-before`, `--started-after`, `--started-before`, `--stopped-after`, `--stopped-before`
* `abs experiments metrics results --from`, `--to`
* `abs activity-feed list --since`
* `abs events list --from`, `--to`
* `abs events history --from`, `--to`
* `abs events json-values --from`, `--to`
* `abs events json-layouts --from`, `--to`
* `abs insights velocity --from`, `--to` (and `decisions`, `velocity-detail`, `decisions-history`)

```bash
abs experiments list --created-after 7d                  # last 7 days
abs experiments list --stopped-after "30 days ago"       # stopped in last month
abs experiments list --started-after yesterday
abs experiments list --created-after 2024-01-01          # since Jan 1 2024
abs experiments metrics results 123 --from 7d --to now
abs activity-feed list --since 1h
abs events list --from 2w --to yesterday
```
