Skip to content

Configuration

The Contox CLI uses a layered configuration system. Settings can come from three sources, resolved in the following order of precedence (highest first):

  1. Environment variables
  2. Project config (.contox.json)
  3. Global config (~/.contoxrc)

Command-line flags, when provided, always take the highest precedence and override all other sources.

Global config: ~/.contoxrc

The global configuration file lives in your home directory. It is created and updated by the contox login command.

json
{
  "apiKey": "ctx_abc123...",
  "apiUrl": "https://contox.dev",
  "teamId": "team_xyz",
  "projectId": "proj_abc",
  "hmacSecret": "hmac_secret_value"
}
FieldDescription
apiKeyYour Contox API key, used for authentication with the platform
apiUrlThe API base URL. Defaults to https://contox.dev if not set
teamIdDefault team ID, used when no project-level config is present
projectIdDefault project ID, used as a fallback
hmacSecretHMAC secret for request signing, if applicable

This file is created automatically when you run:

bash
contox login -k <your-api-key>

Project config: .contox.json

The project configuration file lives in your project root directory. It is created by the contox init command and should be committed to version control so all team members share the same project binding.

json
{
  "teamId": "team_xyz",
  "projectId": "proj_abc",
  "projectName": "My Project"
}
FieldDescription
teamIdThe team this project belongs to
projectIdThe unique project identifier on the Contox platform
projectNameA human-readable name for the project

Create this file by running:

bash
contox init -t <team-id> -n "My Project"

Or link to an existing project:

bash
contox init -t <team-id> -p <project-id>

Environment variables

Environment variables override both config files. They are useful for CI/CD pipelines, Docker containers, and environments where config files are not practical.

VariableMaps toDescription
CONTOX_API_KEYapiKeyAPI key for authentication
CONTOX_API_URLapiUrlAPI base URL
CONTOX_TEAM_IDteamIdTeam identifier
CONTOX_PROJECT_IDprojectIdProject identifier

Example: CI/CD usage

bash
export CONTOX_API_KEY="ctx_abc123..."
export CONTOX_TEAM_ID="team_xyz"
export CONTOX_PROJECT_ID="proj_abc"

contox scan --dry-run
contox memory --json

Precedence example

If your ~/.contoxrc has projectId: "proj_a", your .contox.json has projectId: "proj_b", and you set CONTOX_PROJECT_ID=proj_c, the resolved project ID will be proj_c (environment variable wins).

If you then run contox status -p proj_d, the resolved project ID will be proj_d (command-line flag wins over everything).

Verifying your configuration

To see the current resolved configuration:

bash
contox whoami

This shows the config file path, API URL, a masked version of your API key, and your authentication status.