# DBIS AS4 Settlement Directory Service Specification

**Date**: 2026-01-19  
**Version**: 1.0.0

---

## 1. Overview

The Directory Service maintains a registry of AS4 settlement members, their endpoints, certificates, and routing configuration.

## 2. Functional Requirements

### 2.1 Member Registry

- Member identification (Member ID)
- Organization information
- Contact details
- Capacity tier
- Status (active, suspended, terminated)

### 2.2 Endpoint Management

- AS4 endpoint URLs
- Protocol versions supported
- Message types allowed
- Service capabilities

### 2.3 Certificate Management

- TLS certificate fingerprints
- Signing certificate fingerprints
- Encryption certificate fingerprints
- Certificate validity periods
- Certificate status

### 2.4 Routing Configuration

- Cutoff windows (per corridor, per currency)
- Routing groups
- Priority levels
- Value date rules

### 2.5 Capability Management

- Supported message types
- Supported currencies
- Supported corridors
- Feature flags

## 3. Data Model

### 3.1 Member Record

```typescript
interface MemberRecord {
  memberId: string;
  organizationName: string;
  capacityTier: number;
  status: 'active' | 'suspended' | 'terminated';
  as4EndpointUrl: string;
  tlsCertFingerprint: string;
  signingCertFingerprint?: string;
  encryptionCertFingerprint?: string;
  allowedMessageTypes: string[];
  supportedCurrencies: string[];
  cutoffWindows: CutoffWindow[];
  routingGroups: string[];
  createdAt: Date;
  updatedAt: Date;
}
```

### 3.2 Cutoff Window

```typescript
interface CutoffWindow {
  corridor: string;
  currency: string;
  cutoffTime: string; // HH:mm UTC
  valueDateRule: 'same-day' | 'next-day';
  timezone?: string;
}
```

## 4. API Specification

### 4.1 Member Lookup

**GET** `/api/v1/as4/directory/members/{memberId}`

Returns member record with all configuration.

### 4.2 Member Search

**GET** `/api/v1/as4/directory/members?status=active&capacityTier=1`

Search members by criteria.

### 4.3 Certificate Lookup

**GET** `/api/v1/as4/directory/members/{memberId}/certificates`

Returns all certificates for a member.

### 4.4 Endpoint Discovery

**GET** `/api/v1/as4/directory/members/{memberId}/endpoint`

Returns AS4 endpoint configuration.

### 4.5 Directory Updates

**POST** `/api/v1/as4/directory/members/{memberId}/update`

Update member configuration (requires authorization).

## 5. Security

### 5.1 Access Control

- Read access: All authenticated members
- Write access: Member owner or DBIS admin
- Certificate updates: Member owner only

### 5.2 Data Integrity

- Directory updates signed
- Version control for changes
- Audit trail for all modifications

### 5.3 Availability

- High availability (99.9% target)
- Replication for redundancy
- Caching for performance

## 6. Versioning

### 6.1 Directory Versions

- Directory updates versioned
- Version numbers incremented on changes
- Members can query specific versions

### 6.2 Change Notifications

- Members notified of directory updates
- Webhook support for real-time updates
- Change log available via API

## 7. Integration

### 7.1 AS4 Gateway Integration

- Gateway queries directory for routing
- Certificate validation uses directory
- Endpoint discovery uses directory

### 7.2 Member Onboarding

- New members registered in directory
- Certificates registered during onboarding
- Configuration set during provisioning

### 7.3 Marketplace Integration

- Directory updated from marketplace subscriptions
- Member status synced with IRU subscriptions
- Capacity tier from marketplace tier

## 8. Performance

### 8.1 Caching

- Directory data cached in gateway
- Cache invalidation on updates
- TTL-based cache expiration

### 8.2 Query Optimization

- Indexed lookups by member ID
- Indexed searches by status, tier
- Efficient certificate fingerprint lookups

## 9. Monitoring

### 8.1 Metrics

- Directory query latency
- Cache hit rates
- Update frequency
- Member count by status

### 9.2 Alerts

- Directory service unavailable
- Certificate expiration warnings
- Member status changes
- High query error rates

---

**End of Specification**
