Skip to content

Time fields

Most times in OriginChats are Unix timestamps in seconds, often with a fractional part, such as 1788177600.412. A few fields use milliseconds instead. This page lists which is which.

Field Unit
Message timestamp, signed_at, edited_at Unix seconds
Channel and thread last_message, channel last_message_by_user Unix seconds
Thread created_at, pinned_at Unix seconds
Poll created_at, expires_at, ended_at Unix seconds
Report created_at, resolved_at Unix seconds
Audit log entry timestamp Unix seconds
Attachment expires_at, invite expires_at Unix seconds
Webhook created_at Unix seconds
Handshake server_time Unix seconds
ping fields sent_at, server_time, server_received_at, server_sent_at Unix seconds
unreads_ack and unreads_update last_viewed Unix seconds
rate_limit.last_message_timestamp Unix seconds
messages_search filters before and after Unix seconds. Values above 100,000,000,000 are read as milliseconds.
server_maintenance status started_at Unix milliseconds
Field Unit
rate_limit.length Milliseconds remaining
typing.duration Milliseconds. Default 6000.
user_timeout.duration Seconds
Channel slow_mode_cooldown, rate_limit.cooldown Seconds
Poll input duration_hours Hours
invite_create expires_in Seconds
Attachment upload expires_in_days Days
server_stats.uptime Whole seconds

Store values as the server sent them. Convert only where you need to, for example multiply seconds by 1000 before passing them to JavaScript’s Date.

ping lets you measure how far your clock is from the server’s. It matters for signing, where the server rejects timestamps more than five minutes off.

  1. Record your send time t0 and put it in sent_at.
  2. The server replies with server_received_at (t1) and server_sent_at (t2).
  3. Record your receive time t3.

Using the same unit for all four:

round trip = (t3 - t0) - (t2 - t1)
offset = ((t1 - t0) + (t2 - t3)) / 2

Add offset to your clock to get the server’s time. The estimate assumes the network delay is the same in both directions, so it’s less accurate when it isn’t.