🧩API

The Conserver provides a REST API built on FastAPI for managing vCons, chains, configuration, and more. The API supports both internal operations and external partner integrations with scoped authentication.

Base URL

The API is served at the path configured by the API_ROOT_PATH environment variable (default: /api).

Authorization

The Conserver API supports two authentication models:

Internal API Authentication

For full system access, use the main API token via the x-conserver-api-token header (or custom header name via CONSERVER_HEADER_NAME).

curl -H "x-conserver-api-token: your-api-token" \
  "http://localhost:8000/api/vcon"

Configure the API token via environment variables:

Variable
Description

CONSERVER_API_TOKEN

Single API token for authentication

CONSERVER_API_TOKEN_FILE

Path to file containing API tokens (one per line)

CONSERVER_HEADER_NAME

Custom header name (default: x-conserver-api-token)

When neither CONSERVER_API_TOKEN nor CONSERVER_API_TOKEN_FILE is set, authentication is disabled.

External Ingress Authentication

For external partners, use ingress-specific API keys that only allow access to designated ingress lists. Configure in config.yml:

External partners can only use the /vcon/external-ingress endpoint with their scoped keys.


vCon Management

List vCon UUIDs

Retrieves a paginated list of vCon UUIDs, sorted by timestamp (newest first).

Query Parameters:

Parameter
Type
Description
Default

page

int

Page number (1-indexed)

1

size

int

Items per page

50

since

datetime

Filter vCons created after this date

(none)

until

datetime

Filter vCons created before this date

(none)

Response: 200 OK

Example:


Get vCon by UUID

Retrieves a single vCon by its UUID. First checks Redis, then falls back to configured storage backends.

Response: 200 OK - Returns the full vCon JSON

Response: 404 Not Found - vCon not found

Example:


Get Multiple vCons

Retrieves multiple vCons by their UUIDs in a single request.

Query Parameters:

Parameter
Type
Description

vcon_uuids

List[UUID]

List of vCon UUIDs to retrieve

Response: 200 OK

Example:


Create vCon

Stores a new vCon in Redis and indexes it for searching.

Query Parameters:

Parameter
Type
Description

ingress_lists

List[str]

Optional ingress queues to add the vCon to

Request Body: Full vCon JSON object

Response: 201 Created - Returns the stored vCon

Example:


Delete vCon

Removes a vCon from Redis and all configured storage backends.

Response: 204 No Content

Example:


Search vCons

Search for vCons by party information (phone, email, name). At least one parameter is required. Multiple parameters use AND logic.

Query Parameters:

Parameter
Type
Description

tel

string

Phone number to search for

mailto

string

Email address to search for

name

string

Party name to search for

Response: 200 OK

Example:


External Partner API

Submit External vCon

Endpoint for external partners to submit vCons with scoped API access. Each API key is restricted to specific ingress lists.

Authentication: Uses ingress-specific API keys configured in ingress_auth

Query Parameters:

Parameter
Type
Description

ingress_list

string

Target ingress queue (must match API key permissions)

Request Body: Full vCon JSON object

Response: 204 No Content

Response: 403 Forbidden - Invalid API key or unauthorized ingress list

Example:

Security Model:

  • Each API key grants access only to predefined ingress list(s)

  • No access to other API endpoints or system resources

  • Multiple API keys can be configured per ingress list

  • Submitted vCons are automatically stored, indexed, and queued


Chain Management

Add to Ingress

Adds vCon UUIDs to a processing chain's ingress list.

Query Parameters:

Parameter
Type
Description

ingress_list

string

Name of the ingress list

Request Body:

Response: 204 No Content

Example:


Get from Egress

Removes and returns vCon UUIDs from a chain's egress list.

Query Parameters:

Parameter
Type
Description
Default

egress_list

string

Name of the egress list

(required)

limit

int

Maximum UUIDs to remove

1

Response: 204 No Content with body:

Example:


Count Egress Queue

Returns the number of vCons in an egress list.

Query Parameters:

Parameter
Type
Description

egress_list

string

Name of the egress list

Response: 200 OK


Configuration

Get Configuration

Returns the current system configuration from the YAML file.

Response: 200 OK - Returns full configuration as JSON


Update Configuration

Updates the system configuration file.

Request Body: Full configuration as JSON

Response: 204 No Content

Note: Changes take effect immediately for new chain processing.


Dead Letter Queue

When vCon processing fails, the vCon UUID is moved to a Dead Letter Queue (DLQ). Each ingress list has an associated DLQ named {ingress_list}:dlq.

Get DLQ Contents

Returns all vCon UUIDs in a dead letter queue.

Query Parameters:

Parameter
Type
Description

ingress_list

string

Name of the ingress list

Response: 200 OK

Example:


Reprocess DLQ

Moves all items from a DLQ back to the original ingress list for reprocessing.

Query Parameters:

Parameter
Type
Description

ingress_list

string

Name of the ingress list

Response: 200 OK

Example:


Lifecycle

Rebuild Search Index

Rebuilds the search index for all vCons in Redis. Useful after bulk imports or to refresh expired indices.

Response: 200 OK


Redis Caching Behavior

When a vCon is requested but not found in Redis:

  1. The API checks each configured storage backend

  2. If found, the vCon is stored back in Redis with TTL (VCON_REDIS_EXPIRY, default 1 hour)

  3. The vCon is added to the sorted set for timestamp-based retrieval

  4. Subsequent requests are served from Redis

Configure caching with environment variables:

Variable
Description
Default

VCON_REDIS_EXPIRY

Redis cache TTL in seconds

3600 (1 hour)

VCON_INDEX_EXPIRY

Search index TTL in seconds

86400 (24 hours)


Error Responses

All endpoints return standard HTTP error codes:

Code
Description

400

Bad Request - Invalid parameters

403

Forbidden - Invalid or missing API key

404

Not Found - Resource doesn't exist

500

Internal Server Error - Processing failure

Error response format:

Last updated

Was this helpful?