Skip to main content
The Palyra daemon (palyrad) exposes a multi-surface HTTP API designed for administrative control, operator interaction via the Web Console, and third-party LLM client compatibility. These interfaces provide RESTful access to the core engine’s state, including session management, policy evaluation, and tool execution.

API Surfaces Overview

The daemon segments its HTTP routes into three primary namespaces, each with distinct authentication and authorization requirements:
  1. Admin API (/admin/v1/*): Low-level diagnostic and security management. Requires a static admin_token (Bearer auth) crates/palyra-daemon/tests/admin_surface.rs#48-60.
  2. Console API (/console/v1/*): Powering the React-based Web Console. Uses session-based authentication (cookies) and CSRF protection for mutating requests apps/web/src/consoleApi.test.ts#44-90.
  3. Compatibility API (/v1/*): Provides an OpenAI-compatible interface for existing tools and SDKs crates/palyra-daemon/src/transport/http/handlers/compat.rs#128-132.

Request Context and Security

Every request to the Admin or Console surfaces must include context headers that define the “Principal” (who is acting) and the “Device” (where the action originates).
HeaderDescriptionExample
x-palyra-principalThe identity string of the caller.admin:web-console
x-palyra-device-idA unique identifier for the calling device.01ARZ3NDEKTSV4RRFFQ69G5FAV
x-palyra-channelThe communication medium (cli, web, discord).web
x-palyra-csrf-tokenRequired for all POST/PUT/DELETE in Console API.(Secure Hash)
Sources: crates/palyra-daemon/tests/admin_surface.rs#57-60, apps/web/src/consoleApi.test.ts#88-90

Admin API (/admin/v1/*)

The Admin API is used for system-level introspection and security auditing. It is primarily consumed by the palyra CLI.

Key Endpoints

Admin Request Flow

Title: Admin Request Validation Flow Sources: crates/palyra-daemon/tests/admin_surface.rs#30-72, crates/palyra-daemon/src/app/runtime.rs#62-63

Console API (/console/v1/*)

The Console API supports the Web Console (apps/web). It manages complex state transitions for agents, routines (cron jobs), and chat sessions.

Authentication & Session Lifecycle

The ConsoleApiClient in the frontend manages a multi-step bootstrap process:
  1. Login: POST /console/v1/auth/login exchanges an admin token or handoff token for a ConsoleSession crates/palyra-daemon/src/transport/http/handlers/console/auth.rs#19-111.
  2. Session Cookie: The daemon sets a SET-COOKIE header with a secure session token crates/palyra-daemon/src/transport/http/handlers/console/auth.rs#104-106.
  3. CSRF Protection: The ConsoleSession object contains a csrf_token which must be sent in the x-palyra-csrf-token header for all mutating requests apps/web/src/consoleApi.test.ts#44-53.

Routine Management (/console/v1/routines)

Routines are managed via the RoutineRegistry and CronService.

Agent & Workspace Management

Sources: apps/web/src/consoleApi.ts#17-49, crates/palyra-daemon/src/transport/http/handlers/console/auth.rs#19-111, crates/palyra-daemon/src/transport/http/handlers/console/routines.rs#154-215

Compatibility API (/v1/*)

Palyra provides a compatibility layer for tools expecting an OpenAI-style API. This allows Palyra to act as a drop-in replacement for local model orchestration.

API Token Security

Unlike the Console API, the Compatibility API uses ApiTokenRecord managed by the AccessRegistry. Tokens can be scoped to specific permissions like compat.chat.create crates/palyra-daemon/src/access_control.rs#24-26. Title: Compatibility API Request Processing Sources: crates/palyra-daemon/src/transport/http/handlers/compat.rs#128-149, crates/palyra-daemon/src/access_control.rs#151-173

Data Structures

Console Session

The ConsoleSession represents an active operator session in the Web Console.
FieldTypeDescription
principalStringThe authenticated principal (e.g., admin:web-console).
csrf_tokenStringToken used to prevent Cross-Site Request Forgery.
issued_at_unix_msi64Timestamp of session creation.
expires_at_unix_msi64Timestamp of session expiration.
Sources: crates/palyra-control-plane/src/models.rs#8-16

Deployment Posture

The /admin/v1/status endpoint returns a DeploymentPostureSummary, providing a snapshot of the daemon’s security configuration.
FieldTypeDescription
modeStringDeployment mode (e.g., standalone, cluster).
admin_auth_requiredboolWhether the /admin surface requires a token.
tlsTlsSummaryStatus of Gateway TLS.
remote_bind_detectedboolSecurity warning if binding to non-loopback without auth.
Sources: crates/palyra-control-plane/src/models.rs#48-61

Rate Limiting

The daemon implements per-IP and per-token rate limiting to prevent brute-force attacks and resource exhaustion. Sources: crates/palyra-daemon/src/app/runtime.rs#62-66, crates/palyra-daemon/src/transport/http/handlers/compat.rs#111