YACS

HTTP API

All endpoints are under /api. Authentication uses the YACSSESSION cookie set by /api/init or a login endpoint. Request bodies are JSON unless noted; uploads are multipart/form-data.

Endpoints that return protobuf messages respond with binary protobuf when you send Accept: application/x-protobuf, and protobuf JSON otherwise. See Architecture → Wire format.

Requests are rate limited (100 per minute per client by default). Errors use standard status codes with a message body — 401 unauthenticated, 404 not found, 413 upload too large, 422 validation error, 429 rate limited, 503 feature not configured.

Session

MethodPathAuthDescription
GET/init—Returns the current session, or creates a guest user and device and sets the cookie.
GET/config—Client config: VAPID public key, Google client ID, max image size.
GET/login/:token—Consume a one-time device login token and redirect to /.
POST/login/googleguestBody { token } (Google ID token). Signs in or upgrades the guest.
POST/logout✓Sign out and remove the current device.
GET/me✓Current session (user, device, token).
GET/health—Health check used by Docker.

Profile & account

MethodPathDescription
GET/profileCurrent user's profile.
PUT/profileUpdate name, about, labels, etc.
PUT/profile/avatarUpload avatar (photo field, multipart).
DELETE/profile/avatarRemove avatar.
PUT/profile/locationUpdate location for Nearby.
PUT/profile/searchableToggle Nearby visibility.
POST/profile/notifications/subscribeRegister a Web Push subscription.
POST/profile/notifications/settingUpdate notification preferences.
DELETE/accountDelete the account.

Devices

MethodPathDescription
GET/devicesList devices (_id, ip, name).
POST/devicesCreate a device and a one-time login token valid for 2 hours. Returns { device, token }; the login URL is /api/login/<token>.
DELETE/devices/:deviceRemove a device.

Users & discovery

MethodPathDescription
GET/users/:userA user's public profile.
POST/connect/:userOpen (or find) a direct conversation with a user.
GET/discover/usersNearby users. Query: distance (km, default 1), label[] (repeatable).
GET/discover/users/:userA discoverable user's profile.
GET/labelsAll labels.

Conversations

MethodPathDescription
GET/conversationsList conversations.
POST/conversationsCreate a conversation (returns its invitation code).
POST/conversations/acceptBody { code }. Accept an invitation.
GET/conversations/:conversationGet one conversation.
PUT/conversations/:conversationUpdate (e.g. group name).
DELETE/conversations/:conversationLeave/delete.
GET/conversations/:conversation/usersMembers.
POST/conversations/:conversation/usersAdd members (groups).
DELETE/conversations/:conversation/users/:userRemove a member.
POST/conversations/:conversation/connectBody { username }. Invite a public user by username.

Messages

MethodPathDescription
GET/conversations/:conversation/messagesMessage history.
POST/conversations/:conversation/send-fileUpload an image (file field, multipart).
POST/conversations/:conversation/messages/removeDelete messages.
POST/conversations/:conversation/messages/syncedMark messages as synced to this device.
PUT/messages/:messageEdit a message.
POST/envelopesRelay an envelope (yacs.v1.EnvelopeSend).

Calls

MethodPathDescription
POST/conversations/:conversation/callStart a call.
POST/calls/:message/rejectReject an incoming call.
GET/calls/ice-serversSTUN/TURN servers with short-lived TURN credentials.

Example

# Create a guest session and keep the cookie
curl -c jar.txt http://localhost:3000/api/init

# List conversations as JSON
curl -b jar.txt http://localhost:3000/api/conversations