CLEMA protocol

Rate Limits

Requests that are cheap to send and expensive to serve are throttled. Exceeding a limit yields the rate_limited error; typing.set signals are silently dropped instead, since they carry no response.

Commands Scope Budget
auth.phone, phone.set client address 10 per minute
auth.qr client address 20 per minute
invite.get and link.open together client address 30 per minute
auth.token, auth.refresh client address 60 per minute
auth.code, phone.code client address 30 per minute
auth.code, phone.code phone number 1 code per 60 seconds; 5 SMS and 10 codes each other way per day
auth.code, phone.code client address 10 codes per hour; 30 codes by channels per day, 100 from an IPv6 /48
phone.code account 3 numbers per day
auth.code, phone.code channel codes a day and numbers reached, set by the server
auth.code, phone.code country codes by channels to new numbers an hour and a day, set by the service
auth.code, phone.code number none while it rests, 14 days after its account was deleted
auth.phone, phone.set verification 5 wrong codes
phonebook.update account 10000 entries added per day
user.search, conversation.search, message.search, phonebook.update, phonebook.match connection 20 per 30 seconds
Message, voice play, read, delivery, draft, notification, reactions-seen, pin, block, privacy, moderation, contact, personal link, profile, presence, session, transport, push, activity, conversation, membership and invitation changes; code.get, qr.get, qr.accept; typing.set; phonebook.clear; files and transfers but file.get; calls but call.create connection 40 per 2 seconds
call.create account 10 per minute

Credential checks are limited per client address rather than per connection, so reconnecting does not reset the budget; an IPv6 address counts by its /64, what one subscriber is given. Every code but one in the app costs money, and a stream of codes to premium-rate numbers is a known way to spend someone else's: sending is therefore limited by number, address and account at once, a server caps what each channel sends in a day, and a channel reaches only the numbers the server lets it — a code no way can send is delivery_failed, with retry_after when the ways are spent for a while. The limits of codes count the codes sent over the time each is for, wherever they were asked for and whichever server sent them; a code that went nowhere counts against none of them. A rate_limited answer to a code request carries retry_after. Behind a reverse proxy the address is taken from X-Forwarded-For, but only when the proxy is configured as trusted — otherwise every client would share the proxy's address, or be able to claim any address it likes.