Skip to main content
All Docs
FeaturesmyProp (AgentOS People Portal)Updated April 3, 2026

AgentOS Environment Configuration Service

AgentOS Environment Configuration Service

The src/lib/letmc/config.ts module provides a server-side utility for resolving AgentOS (letmc.com) API credentials and endpoint configuration from environment variables. It handles environment detection, URL validation, and offers both throwing and safe access patterns.

Overview

All AgentOS API integration in myProp flows through this configuration service. It reads environment variables at runtime, determines the correct deployment context, validates the base URL, and provides helper utilities for building API requests.

Exported API

isLetmcConfigured(): boolean

Returns true when LETMC_API_KEY is set and non-empty. Use this as a guard before calling getLetmcConfig() in code paths where the AgentOS integration is optional.

import { isLetmcConfigured } from "@/lib/letmc/config";

if (!isLetmcConfigured()) {
  // Integration not set up — skip or show setup prompt
}

getLetmcConfig(): LetmcConfig

Resolves and validates the full configuration. Returns a LetmcConfig object.

Throws if:

  • LETMC_API_KEY is missing or empty.
  • LETMC_API_BASE_URL is set but is not a valid http/https URL.
import { getLetmcConfig } from "@/lib/letmc/config";

const config = getLetmcConfig();
// config.apiBaseUrl   — resolved base URL (no trailing slash)
// config.apiKey       — API key string
// config.environment  — "production" | "staging" | "development"
// config.isBaseUrlOverridden — true if LETMC_API_BASE_URL was set

LetmcConfig shape:

interface LetmcConfig {
  apiBaseUrl: string;          // Fully-qualified base URL, no trailing slash
  apiKey: string;              // AgentOS API key
  environment: LetmcEnvironment; // "production" | "staging" | "development"
  isBaseUrlOverridden: boolean;  // true when LETMC_API_BASE_URL is set
}

getLetmcConfigSafe(): LetmcConfig | null

A non-throwing variant of getLetmcConfig(). Returns null if the integration is not configured or if configuration is invalid. Configuration errors are logged as warnings.

Use this in optional feature paths where a missing AgentOS configuration should degrade gracefully rather than crash.

import { getLetmcConfigSafe } from "@/lib/letmc/config";

const config = getLetmcConfigSafe();
if (!config) {
  // AgentOS not available — skip feature
  return;
}

buildLetmcUrl(path: string, config?: LetmcConfig): string

Builds a fully-qualified AgentOS API URL from a relative path. Optionally accepts a pre-resolved LetmcConfig to avoid re-reading environment variables on repeated calls.

import { buildLetmcUrl } from "@/lib/letmc/config";

buildLetmcUrl("/v3/lettings/properties");
// => "https://live-api.letmc.com/v3/lettings/properties"

// With a pre-resolved config:
const config = getLetmcConfig();
buildLetmcUrl("/v3/lettings/properties", config);

Leading slashes on path are optional — they are normalised automatically.


Environment Variables

VariableRequiredDefaultDescription
LETMC_API_KEYYes (for integration)API key for authenticating with the AgentOS API. Obtain from your AgentOS account dashboard.
LETMC_API_BASE_URLNohttps://live-api.letmc.comOverride the API base URL. Must be a valid http/https URL. Trailing slashes are stripped automatically.
LETMC_ENVNoDerivedExplicit environment override. Accepts: production, staging, preview, development, dev.

Note: LETMC_API_KEY must be set for getLetmcConfig() and buildLetmcUrl() to work. isLetmcConfigured() and getLetmcConfigSafe() are safe to call without it.


Environment Resolution

The service detects the current deployment environment using the following priority chain:

  1. LETMC_ENV — Explicit override. Takes highest priority. Useful for per-branch or per-environment configuration.

    • productionproduction
    • staging or previewstaging
    • development or devdevelopment
  2. VERCEL_ENV — Automatically set by the Vercel platform.

    • productionproduction
    • previewstaging
    • developmentdevelopment
  3. NODE_ENV — Standard Node.js environment variable.

    • productionproduction
    • teststaging
  4. Default — Falls back to development if none of the above are set.


URL Handling

  • The default base URL is https://live-api.letmc.com (the AgentOS production API endpoint).
  • LETMC_API_BASE_URL overrides this — useful for staging or custom deployments.
  • Non-http/https schemes (e.g. ftp://) are rejected with an error.
  • Trailing slashes are automatically stripped to ensure consistent URL construction when using buildLetmcUrl().

Middleware — Auth Bypass for Internal Routes

The Next.js middleware matcher has been updated so that internal API routes are excluded from authentication checks. The following paths bypass auth middleware automatically:

  • /api/health
  • /api/inngest
  • /api/trpc
  • /api/webhooks
  • /api/billing
  • /api/feedback
  • /api/platform-manifest
  • /api/shell-version
  • /api/revalidate
  • /api/waitlist

This prevents authentication redirects from interfering with system integrations, background workers, and health-check endpoints.