Complete guide to installing, configuring, and testing the Codat CLI.
- Prerequisites
- Installation Methods
- Post-Installation Setup
- Verification
- Troubleshooting
- Uninstallation
- Node.js: Version 18.0.0 or higher
- npm: Version 8.0.0 or higher (comes with Node.js)
- jq: For JSON processing in scripts (
brew install jqorapt-get install jq) - Git: For installing from source
# Check Node.js version
node --version
# Should output: v18.x.x or higher
# Check npm version
npm --version
# Should output: 8.x.x or higherIf you need to install or upgrade Node.js:
- macOS:
brew install nodeor download from nodejs.org - Linux:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - && sudo apt-get install -y nodejs - Windows: Download installer from nodejs.org
Install the CLI globally so it's available from anywhere:
npm install -g @ktmcp-cli/codatThis installs the codat command globally on your system.
Verify installation:
codat --version
codat --helpInstall as a project dependency:
# In your project directory
npm install @ktmcp-cli/codat
# Run via npx
npx codat --help
# Or add to package.json scripts
# "scripts": {
# "codat": "codat"
# }
npm run codat -- --helpClone and install from the repository:
# Clone repository
git clone https://github.com/your-org/codat-cli.git
cd codat-cli
# Install dependencies
npm install
# Link for global use (development mode)
npm link
# Verify
codat --versionFor development:
# Make changes to the code
# Test immediately
node bin/codat.js --help
# Or use the linked command
codat --helpTo unlink:
npm unlink -g @ktmcp-cli/codatCreate a Dockerfile:
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --production
COPY . .
RUN npm link
ENTRYPOINT ["codat"]
CMD ["--help"]Build and run:
# Build image
docker build -t codat-cli .
# Run
docker run --rm \
-e CODAT_API_KEY="your-api-key" \
codat-cli companies list- Go to Codat Dashboard
- Sign up or log in
- Navigate to Developers → API Keys
- Create a new API key or copy an existing one
Option A: Interactive Login
codat auth login
# Follow the prompts to enter your API keyOption B: Command Line
codat auth login YOUR_API_KEY_HEREOption C: Environment Variable
export CODAT_API_KEY="YOUR_API_KEY_HERE"Add to your shell profile for persistence:
# For bash
echo 'export CODAT_API_KEY="YOUR_API_KEY_HERE"' >> ~/.bashrc
source ~/.bashrc
# For zsh
echo 'export CODAT_API_KEY="YOUR_API_KEY_HERE"' >> ~/.zshrc
source ~/.zshrccodat auth statusExpected output:
Authentication Status
──────────────────────────────────────────────────
✓ Authenticated
API Key: YOUR****HERE
Source: Config file
Config: /Users/you/.config/codat-cli/config.json
# Set default output format
codat auth config --output-format json
# Set default page size
codat auth config --page-size 50
# View all settings
codat auth config# 1. Check version
codat --version
# 2. View help
codat --help
# 3. Test authentication
codat auth status
# 4. List companies (should return your companies or empty list)
codat companies list
# 5. Test a command with JSON output
codat companies list --format json# Create a test company
codat companies create "Test Company $(date +%s)" --format json
# Copy the company ID from output, then
# List its connections (should be empty)
codat connections list COMPANY_ID#!/bin/bash
# test-installation.sh
echo "Testing Codat CLI Installation..."
# Test 1: Version
echo -n "1. Version check... "
if codat --version > /dev/null 2>&1; then
echo "✓"
else
echo "✗"
exit 1
fi
# Test 2: Authentication
echo -n "2. Authentication... "
if codat auth status > /dev/null 2>&1; then
echo "✓"
else
echo "✗"
echo "Please configure authentication with: codat auth login"
exit 1
fi
# Test 3: API Connection
echo -n "3. API connection... "
if codat companies list --format json > /dev/null 2>&1; then
echo "✓"
else
echo "✗"
exit 1
fi
# Test 4: JSON Parsing
echo -n "4. JSON output... "
if codat companies list --format json | jq empty 2>/dev/null; then
echo "✓"
else
echo "✗ (jq not installed or invalid JSON)"
fi
echo ""
echo "All tests passed! ✓"Solution 1: Check npm global bin directory
npm config get prefix
# Should output something like /usr/local
# Verify codat is installed
ls -la $(npm config get prefix)/bin/codat
# Add to PATH if needed
export PATH="$(npm config get prefix)/bin:$PATH"Solution 2: Reinstall globally
npm uninstall -g @ktmcp-cli/codat
npm install -g @ktmcp-cli/codatSolution 3: Use npx
npx @ktmcp-cli/codat --helpmacOS/Linux:
# Option 1: Use sudo (not recommended)
sudo npm install -g @ktmcp-cli/codat
# Option 2: Fix npm permissions (recommended)
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.profile
source ~/.profile
npm install -g @ktmcp-cli/codat# Check current status
codat auth status
# If not authenticated, login
codat auth login YOUR_API_KEY
# Or set environment variable
export CODAT_API_KEY="YOUR_API_KEY"# Reinstall dependencies
cd /path/to/codat-cli
npm install
# If installed globally, reinstall
npm uninstall -g @ktmcp-cli/codat
npm install -g @ktmcp-cli/codat# Verify API key
codat auth status
# Test with new key
codat auth logout
codat auth login NEW_API_KEY
# Verify key is valid at https://app.codat.io/developers/api-keys# Check error message for retry-after time
# Wait the specified time, then retry
# For scripts, add delays between requests
sleep 1 # Wait 1 second between requests# Uninstall CLI
npm uninstall -g @ktmcp-cli/codat
# Remove configuration (optional)
rm -rf ~/.config/codat-cli/
# Verify removal
codat --version
# Should output: command not found# In your project directory
npm uninstall @ktmcp-cli/codat
# Remove from package.json if manually added# Unlink
npm unlink -g @ktmcp-cli/codat
# Remove repository
rm -rf /path/to/codat-cli# Update to latest version
npm update -g @ktmcp-cli/codat
# Or reinstall
npm uninstall -g @ktmcp-cli/codat
npm install -g @ktmcp-cli/codat
# Check new version
codat --versionnpm update @ktmcp-cli/codat
# Or specify version
npm install @ktmcp-cli/codat@latestUsing Homebrew (if available):
# Install Node.js
brew install node
# Install CLI
npm install -g @ktmcp-cli/codatPermissions:
- macOS might require admin privileges for global installs
- Consider using
~/.npm-globalapproach (see troubleshooting)
# Install Node.js
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
# Install CLI
npm install -g @ktmcp-cli/codat
# If permission issues
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrcUsing Node.js installer:
- Download from nodejs.org
- Run installer
- Open Command Prompt or PowerShell
- Run:
npm install -g @ktmcp-cli/codat
Using Windows Terminal:
# Install
npm install -g @ktmcp-cli/codat
# Run
codat --helpPath issues:
- Ensure npm global directory is in PATH
- Restart terminal after installation
After successful installation:
- Read Quick Start: QUICKSTART.md
- Explore Examples: EXAMPLES.md
- Browse Documentation: README.md
- Create first company:
codat companies create "My Company"
If you encounter issues not covered here:
- Check README.md troubleshooting section
- Review error messages carefully (they include hints)
- Verify Node.js and npm versions
- Try reinstalling with
npm install -g @ktmcp-cli/codat
You're ready to use the Codat CLI! 🚀