paperclipai/paperclip · error · Error
Current company is not available. Pass --company-id, set PAP
Error message
Current company is not available. Pass --company-id, set PAPERCLIP_COMPANY_ID, set a context profile companyId, or authenticate with an agent API key.
What it means
Thrown in resolveCurrentCompanyId() when GET /api/agents/me returns 401 or 403. This is the first of two identical-message throws: this one fires specifically on an authentication/authorization failure hitting the agent-me endpoint, meaning the caller has no usable credentials to discover their scoped company.
Source
Thrown at cli/src/commands/client/company.ts:2041
if (isBoardAccessRequiredError(error) || isInstanceAdminRequiredError(error)) {
throw new Error(
"Creating companies requires board/instance-admin authentication. Agent API keys are scoped to one company; use `paperclipai company list --json` or `paperclipai company current --json` to select the scoped company, or rerun create with a board token/login.",
);
}
throw error;
}
}
async function resolveCurrentCompanyId(ctx: { companyId?: string; api: { get<T>(path: string): Promise<T | null> } }): Promise<string> {
const fromContext = ctx.companyId?.trim();
if (fromContext) return fromContext;
let agent: AgentMeResponse | null = null;
try {
agent = await ctx.api.get<AgentMeResponse>("/api/agents/me");
} catch (error) {
if (error instanceof ApiRequestError && (error.status === 401 || error.status === 403)) {
throw new Error(
"Current company is not available. Pass --company-id, set PAPERCLIP_COMPANY_ID, set a context profile companyId, or authenticate with an agent API key.",
);
}
throw error;
}
const fromAgent = agent?.companyId?.trim();
if (fromAgent) return fromAgent;
throw new Error(
"Current company is not available. Pass --company-id, set PAPERCLIP_COMPANY_ID, set a context profile companyId, or authenticate with an agent API key.",
);
}
function isBoardAccessRequiredError(error: unknown): error is ApiRequestError {
return error instanceof ApiRequestError && error.status === 403 && error.message.toLowerCase().includes("board access required");
}
function isInstanceAdminRequiredError(error: unknown): error is ApiRequestError {View on GitHub (pinned to 67001ec6eb)
Solutions
- Provide the company explicitly: `--company-id <id>`, or set PAPERCLIP_COMPANY_ID.
- Authenticate: run `paperclipai connect` or set a valid PAPERCLIP_API_KEY in the referenced env var.
- Run `paperclipai context current` to confirm the active profile and its API key env var.
Example fix
# before paperclipai company list # after export PAPERCLIP_API_KEY=$(cat ~/.paperclip/board-key) # or pin the company id paperclipai company list --company-id 550e8400-e29b-41d4-a716-446655440000
Defensive patterns
Strategy: validation
Validate before calling
// Ensure a company id is resolvable without hitting /api/agents/me when auth may be missing.
function ensureCompanyId(ctx: { companyId?: string }): string {
const id = ctx.companyId?.trim();
if (!id) {
throw new Error("No company context: pass --company-id, set PAPERCLIP_COMPANY_ID, or authenticate first.");
}
return id;
} Type guard
import { ApiRequestError } from "../../client/http.js";
function isAuth401or403(err: unknown): boolean {
return err instanceof ApiRequestError && (err.status === 401 || err.status === 403);
} Try / catch
try {
agent = await ctx.api.get<AgentMeResponse>("/api/agents/me");
} catch (err) {
if (isAuth401or403(err)) {
throw new Error("Authentication failed; set PAPERCLIP_API_KEY or pass --company-id.");
}
throw err;
} Prevention
- Always set an explicit --company-id or PAPERCLIP_COMPANY_ID in automation.
- Run `paperclipai connect` once interactively to persist credentials.
- Periodically rotate and verify API keys are still valid server-side.
When it happens
Trigger: No API key configured and no --company-id/PAPERCLIP_COMPANY_ID/context companyId set, so the CLI tries /api/agents/me which 401s; an expired or revoked agent token; a malformed Authorization header.
Common situations: Fresh CLI install with no connect/context; token revoked server-side; PAPERCLIP_API_KEY pointing at a deleted key; api-base pointing at a server that does not recognize the token.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- Target existing company requires --company-id (or context de
- Failed to create board token
- Company ID is required.
- Company ID is required. Pass --company-id or set PAPERCLIP_C
- Request failed: ${response.status}
AI-assisted analysis of paperclipai/paperclip@67001ec6eb (2026-08-12).
Data as JSON: /api/errors/e51fe52aa86328af.
Report an issue: GitHub.