Aller au contenu

API reference

Ce contenu n’est pas encore disponible dans votre langue.

The server exposes a REST API consumed by the desktop client. All endpoints return application/json. Errors share a single shape:

{ "error": "error_code", "message": "Human-readable description" }
StatusMeaning
400Validation failure (response also includes an errors array)
401Missing, invalid, or expired JWT
409Sync conflict or quota violation
502Upstream AI provider connection failure
503AI proxy not configured
504Upstream AI provider timeout

DTOs are defined in the Pia.Shared project (net10.0, no Windows dependency). Sync DTOs are prefixed with Sync, server entities with Server. Mapping between layers is explicit — no AutoMapper.

MethodPathAuthRateBody / Params
GET/auth/loginauth?provider=google|microsoft|entraid&redirect_uri=...
GET/auth/callbackauthOAuth implicit redirect
POST/auth/refreshauth{ "refreshToken": "..." }
POST/auth/logoutauth{ "refreshToken": "..." }
GET/auth/meJWTglobal

Login / refresh response:

{ "accessToken": "jwt...", "refreshToken": "opaque-string", "expiresIn": 900 }

Access tokens are JWT (HS256, issuer pia-server, audience pia-client) and live 15 minutes. Refresh tokens are opaque strings stored hashed; rotation is mandatory on every refresh, with a 10-token-per-user cap.

MethodPathAuthRatePurpose
GET/api/sync/pull?since={ISO8601}JWTsyncIncremental pull
POST/api/sync/pushJWTsyncPush client changes
GET/api/sync/statusJWTglobalSync status
GET/api/sync/eventsJWTglobalAudit log
GET/api/sync/quotaJWTglobalUsage stats

Push request (SyncPushRequest):

{
"templates": [...],
"providers": [...],
"sessions": [...],
"memories": [...],
"todos": [...],
"settings": { ... }
}

Push response (SyncPushResponse): server-assigned IDs, conflict list, resolution instructions. Conflicts use SyncConflict with strategy last-write-wins (default) or server-wins.

See the Sync protocol page for the full request lifecycle.

MethodPathAuthRatePurpose
GET/api/ai/statusglobalProxy availability
GET/api/ai/templatesglobalBuilt-in template list
POST/api/ai/optimizeoptionalaiText optimization

Optimize request:

{ "text": "...", "templateId": "...", "providerId": "..." }

text is capped at 10,000 characters. Input is sanitized server-side before forwarding to the upstream provider. The response either streams or returns { "result": "..." }.

The X-Pia-Mode header (values: optimize, assistant, research) selects which configured upstream provider to use. Per-mode overrides are documented under Configuration.

MethodPathAuthRatePurpose
POST/api/e2ee/devices/registerJWTglobalRegister device as Pending
GET/api/e2ee/devicesJWTglobalList user’s devices
POST/api/e2ee/devices/approveJWTglobalApprove a pending device (wrap UMK for it)
POST/api/e2ee/devices/revokeJWTglobalRevoke a device
GET/api/e2ee/devices/wrapped-umk/{deviceId}JWTglobalFetch wrapped UMK for a device
PUT/api/e2ee/devices/wrapped-umkJWTglobalStore wrapped UMK for a device
MethodPathAuthRatePurpose
POST/api/e2ee/recovery/wrapped-umkJWTglobalStore recovery-wrapped UMK
GET/api/e2ee/recovery/wrapped-umkJWTglobalRetrieve recovery-wrapped UMK
POST/api/e2ee/recovery/activateJWTglobalActivate device via recovery code

Located in Pia.Shared:

  • SyncSyncPullResponse, SyncPushRequest, SyncPushResponse, SyncConflict, SyncTemplate, SyncProvider, SyncSession, SyncMemory, SyncTodo, SyncSettings.
  • E2EEDeviceStatus (enum), DeviceInfo, DeviceRegistrationRequest/Response, DeviceApprovalRequest, WrappedUmkBlob, RecoveryWrappedUmkBlob, RecoveryActivationRequest.
  • ModelsBuiltInTemplate.

Serialization uses System.Text.Json with default options.