## Summary Follow-up to #9912. Specification only: closes four gaps in NIP-SL and the NIP-FI "Deferred actions" section. **NIP-SL** - A send-later status (`kind:30361`) is the relay's record of how a scheduled send ended: `sent`, `failed`, `missed` or `cancelled`. It is how the author's client learns the outcome, since the relay posts the message while the client may be offline. The relay signs each status with its NIP-11 `self` key, which NIP-11 makes optional. A relay now serves the `send_later` descriptor only with a `self` key and keeps that key while a status signed with it is readable. A client treats the descriptor as absent when `self` is missing or malformed, and reads the NIP-11 document again, once per key, when a status is signed with another key. Without this, a relay with no `self` or a rotated one makes clients reject these statuses, and a failed send whose text is still retained reads as pending. - An agent admitted through its owner could schedule past the time bound of the NIP-OA `auth` tag that proved the owner, by leaving the tag off the message. The `created_at` conditions of that tag now hold at `T`, and an `auth` tag on the message names the stored owner. - Deleting an instruction covers the instruction's copy of the message, so the wording no longer reads as covering the posted event. **NIP-FI** - An admission's time is read no later than its deny-set check, and the connection's lifetime counts from that time. Otherwise an admission that checked the deny set just before a disconnect committed could be stamped after `recorded_at` and stay unfenced. ### Related issue Follow-up to #9912. ### Testing Documentation only. `git diff --check` passes and the section links in NIP-SL resolve. To review: read the diff; each change is one or two sentences. --------- Signed-off-by: Kalvin Chau <kalvin@block.xyz> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
24 KiB
NIP-SL
Send Later
draft optional relay
This NIP lets an author write a message now and have the relay post it later, while the author's devices are offline. The client signs the message ahead of time and dates it T, the moment it should post, then gives it to the relay inside a private instruction. At T the relay checks that the author may still post, stores the message like any other, and tells the author how the send ended.
The relay never holds the author's key. It posts the message inside the created_at window it already allows for any event, so the signing rule and the timestamp rule do not change. Readers get an ordinary event and cannot tell that it was sent later.
Recurring sends, forum posts and NIP-17 gift wraps are out of scope. There is no time lock: the relay can read a message as soon as it accepts the instruction.
Kinds
| Kind | Name | Signer | Purpose |
|---|---|---|---|
30360 |
Instruction | author | Holds one message to post later, or cancels it |
30361 |
Status | relay | Tells the author how a send ended |
Both kinds are addressable, and only the author can read them. A send is one message waiting to be posted, and its address is (author pubkey, 30360, d). A send is pending until it ends as sent, failed, missed or cancelled. Once it has ended it never becomes pending again.
Instruction
{
"kind": 30360,
"pubkey": "<author>",
"created_at": 1769990000,
"content": "<the signed message, as JSON>",
"tags": [
["d", "a3f8c2e1b4d79600e5d2f1a8c3b6094d"],
["not_before", "1770000000"],
["generation", "1"]
]
}
dis the send id. It MUST be 16 bytes from a cryptographically secure random source, written as 32 lowercase hex characters. It MUST NOT be derived from the message, the channel or the time.not_beforeisT, a Unix timestamp in the format NIP-ER defines for this tag.generationis the version of the send, in the same format. It starts at1.
An instruction MUST have each of these tags exactly once, with one value. It MAY also have one alt tag (NIP-31). Any other tag makes it malformed, so no channel, mention or thread query can match an instruction.
content MUST be the signed message: one JSON object with exactly the members id, pubkey, created_at, kind, tags, content and sig. A missing, extra or repeated member is invalid.
The message MUST pass all of these:
- Its
idandsigverify. - Its
pubkeyis the instruction'spubkey. - Its
created_atequalsnot_beforeexactly. - Its
kindis one the relay lists (Support). - It has exactly one
htag, which names a channel of the community the instruction was sent to.
Apart from that it is an ordinary event of its kind. A thread reply, a message in a DM, a mention, an attachment and an agent's NIP-OA auth tag all look as they would if the author posted the message live.
Cancel
{ "kind": 30360, "content": "", "tags": [["d", "<send id>"], ["generation", "3"]] }
A cancel MUST have exactly one d and one generation tag, at most one alt, no other tag, and empty content.
Changing a send
The first instruction at an address MUST hold a message and have generation 1. Every later one MUST have the stored generation plus one. It MUST also win NIP-01 ordering against the stored one: a greater created_at, or the same created_at and a lower id. If two devices change the same generation, only one succeeds. A client sets created_at to its current time, or to the stored created_at plus one if that is later.
A client changes a pending send by publishing the next generation:
- To edit it or change its time: a newly signed message.
- To send it now:
not_beforeset to the current time, and the message signed for that time. - To cancel it: a cancel, which ends the send.
A client MUST NOT publish the message directly while its send is pending.
Once a send has ended, its address is closed. The relay MUST refuse every later instruction there for at least status_retention after the send ended, and for as long as it stores a status or a cancel for the address. A new attempt uses a fresh d.
NIP-09 does not apply to kind:30360. A relay MUST NOT delete an instruction or change a send because of a deletion request, and SHOULD reject a request that names a kind:30360 event or address.
Relay behavior
Acceptance checks
The relay accepts an instruction wherever it authenticates the sender, such as a NIP-42 session. It runs these checks in order, and the first one that fails decides the answer. A relay MAY add detail after the OK text shown, so clients match only up to the end of it.
| # | Check | OK when it fails |
|---|---|---|
| 1 | The sender is authenticated as the event's pubkey, and id and sig verify |
as for any event |
| 2 | The event is not the instruction already stored at its address | true, duplicate: already have this event |
| 3 | created_at is within the relay's usual tolerance |
as for any event |
| 4 | The tags are those of an instruction or a cancel, and content is at most max_content_len bytes |
invalid: malformed not_before, otherwise invalid: malformed instruction |
| 5 | The address is not closed | invalid: send ended |
| 6 | The generation and ordering rules hold, and a cancel names an existing send | invalid: stale generation, invalid: stale replacement, invalid: no such send |
| 7 | A cancel that passes check 12 is accepted here. The remaining checks apply only to an instruction that holds a message | |
| 8 | The relay is accepting instructions that hold a message: new sends and replacements | restricted: send later disabled |
| 9 | now - 60 <= T and T <= now + max_not_before_delta |
invalid: not_before in the past, invalid: not_before too far |
| 10 | content and the message meet Instruction, and the message passes the relay's validity checks for an ordinary event of its kind, apart from the created_at tolerance |
invalid: message: <reason> |
| 11 | The author may post the message to its channel now: membership, permission to post, channel state, bans and timeouts | restricted: message: <reason> |
| 12 | Under NIP-FI, no disconnect record fences the admission that carried the instruction (Federated identity) | restricted: authorization denied |
| 13 | For a new address, the author has fewer than max_pending pending sends in the community |
restricted: send later quota exceeded |
A relay MUST NOT refuse a cancel because check 8, a timeout or a lost permission to post would refuse a message. max_pending is counted separately for each author key in each community, and an agent's sends count against the agent's own key.
The relay stores an accepted instruction, its generation and the state of the send in one atomic change, and checks 5, 6, 12 and 13 MUST run inside it. A refused instruction MUST change nothing. Once a generation is replaced, the relay MUST NOT release it or keep it readable.
With each generation the relay MUST also store the owner it verified for the author at acceptance, if any. There is no request at release to take an owner from, so release, the banned cancel and the timeout check use the stored one. If a NIP-OA auth tag proved that owner, its created_at conditions MUST hold at T, so an owner's time bound on an agent also bounds what the agent schedules. An auth tag on the message MUST name the stored owner and MUST be valid with its created_at conditions evaluated against T, at acceptance and again at release.
A relay that does not know whether it stored an instruction, as after a storage error, MUST answer error:. A client that gets error: or no OK MUST NOT assume either outcome, and sends the same event again. Only OK true settles an instruction as accepted. After any other answer the client makes a complete read. Before it creates a new send to replace one that is not settled, it MUST check that the message is not readable in its channel.
Release
- The relay MUST NOT store, deliver or return the message before its clock reads
T. - At release it MUST apply every check it would apply if the author posted the message at that moment on an authenticated session: membership, permission to post, channel state, bans, timeouts, attachments, content rules and the author's rate limit. It skips only the proof of a live session, and takes the author's owner from the send.
- It MUST store the message and mark the send
sentin one atomic change, and that change MUST apply only if the send is still pending at the generation being released. A replacement or a cancel therefore either commits first, and the old message is never posted, or is refused withinvalid: send ended. A relay MUST NOT answerOK trueto a cancel and then post the message. - It then does everything it does for a message posted live: delivery, push, mentions, thread counters and search. The stored event is the author's signed event, unchanged.
A refusal listed under failed in Status ends the send at once, even one that would clear inside the window, as a timeout can. The relay tries again only after a rate limit or a transient error. The relay MUST NOT release after T + release_window: a send that is still pending then ends as missed. If the message is already stored at release, the send ends as sent with that event's id.
A relay SHOULD release as soon after T as its checks allow. It MAY spread out sends that share one T, but SHOULD NOT use the rest of the window to delay a release it could make. Clients MUST NOT assume that a message posts at exactly T.
Status
When a send ends, the relay publishes one status. The exception is the author's own cancel, where the cancel is the record.
{
"kind": 30361,
"pubkey": "<relay key>",
"created_at": 1770000004,
"content": "",
"tags": [
["d", "<author pubkey>:<send id>"],
["p", "<author pubkey>"],
["status", "sent"],
["generation", "2"],
["e", "<message id>"],
["expiration", "1772592004"]
]
}
dis the author's pubkey in lowercase hex, a colon and the send id.generationis the generation that ended.eis present only forsent, and holds the id of the stored message.expiration(NIP-40) iscreated_at + status_retention.created_atis the relay's clock when it signs, never earlier than the end of the send.
status |
reason |
The send ends this way when |
|---|---|---|
sent |
The message is stored | |
missed |
It was not released by T + release_window |
|
failed |
not_permitted |
At release, the author is no longer in the channel or the community, or may not post to the channel |
failed |
restricted |
At release, the author or the author's owner is under a timeout in the community |
failed |
archived |
At release, the channel is archived |
failed |
attachment |
At release, an attachment is no longer available |
failed |
rejected |
Release is refused for good for any other reason |
cancelled |
banned |
The author or the author's owner is banned in the community |
cancelled |
disconnected |
A NIP-FI disconnect record fences the admission that carried the send (Federated identity) |
cancelled |
channel_deleted |
The channel is deleted |
cancelled |
withdrawn |
The relay operator ends the send before a version change that could not keep it |
The relay cancels a send in the same atomic change that records the ban, the disconnect or the channel deletion. For a disconnect, that is before it answers the issuer. It MUST apply the banned and channel_deleted rows again at release, which catches an instruction that was being accepted while the ban or the deletion was recorded. An owner here is the owner stored with the send (Acceptance checks).
A cancelled send stays cancelled: lifting a ban or restoring access MUST NOT make it pending again. Deleting an account or a community removes its sends along with the other data, and the relay publishes no status for them.
A relay SHOULD include reason for failed and cancelled, and MUST omit it otherwise. Clients MUST treat a code they do not know as no reason.
A send has at most one status, and the relay MUST NOT revise it. A relay SHOULD store the status in the atomic change that ends the send. If it stores the status afterwards, it MUST record the outcome durably in that change, MUST sign the status when it stores it, and MUST keep trying until the status is stored.
The relay signs a status with its NIP-11 self key, and MUST reject a kind:30361 event that a client submits. Clients MUST accept a status only when its pubkey is that key. A client that gets a status signed with another key MUST read the NIP-11 document again, once for each such key, before it ignores the status.
Reading
A relay MUST NOT reveal the existence, count, tags, content, time or search matches of either kind to anyone but the author. This holds on every read path: REQ, COUNT, live subscriptions, lookups by id, search, HTTP bridges and push.
kind:30360is readable only by a requester authenticated as the event'spubkey.kind:30361is readable only by a requester authenticated as the pubkey in itsptag.- The owner of an agent cannot read the agent's instructions or statuses.
- A relay SHOULD close an unauthenticated request that asks only for these kinds with
auth-required:. When a filter mixes them with other kinds, it MUST omit what the requester may not read.
A client follows its sends with one live subscription. After its EOSE, the relay MUST deliver to it every instruction it accepts and every status it stores.
["REQ", "send-later",
{ "kinds": [30360], "authors": ["<own pubkey>"] },
{ "kinds": [30361], "#p": ["<own pubkey>"] }]
Complete read
The relay's default limit can cut the stored events of that subscription short. An instruction also carries its author's clock, so a since cursor can miss an edit made on another device. A client therefore MUST NOT refresh kind:30360 with since.
Instead it derives state from a complete read after each reconnect: two requests, made as the author, with no since or until. It sends them after the EOSE of the live subscription and keeps that subscription open.
- Instructions:
{"kinds": [30360], "authors": ["<own pubkey>"], "limit": <max_limit>}, with the relay's NIP-11max_limit. - Statuses:
{"kinds": [30361], "#p": ["<own pubkey>"], "#d": [<status d values>], "limit": <number of values>}, split so that no request has more thanmax_limitvalues. The values name every send the client holds as pending or as ended with an unknown outcome, and every send for which request 1 returned an instruction that holds a message.
An event that arrives on the live subscription before the read ends counts as returned. Of two instructions for one address, the client keeps the one that wins NIP-01 ordering. Then, for each send that request 2 names or whose cancel request 1 returned, the first rule that applies gives its state:
- A status was returned: the send ended as the status says.
- An instruction was returned: the send is pending if the instruction holds a message, and cancelled by the author if it is a cancel.
- Neither was returned: the send is not pending and its outcome is unknown. The client MUST NOT show it as sent or as cancelled. It MAY drop a send that has stayed under this rule for
status_retention.
The relay MUST return every event that matches either request, without paging. Retention keeps request 1 within max_limit. The relay MUST answer each request from one consistent view of its storage, so that a replacement in progress cannot hide a pending send. Once a send has ended, the relay MUST NOT serve the instruction that holds its message unless the send's status is readable.
Other reads
Any other read updates only the sends whose events it returns. A read that failed, was closed, came back incomplete or was not authenticated is not evidence of a state. Neither is a lost connection or a live update that never came. A client MUST NOT infer an outcome from any of them.
The relay deletes the instruction of a sent or relay-cancelled send without publishing an event, so a client's copy can be out of date until the status arrives. Before it does, invalid: send ended in answer to an edit or a cancel means that the send is not pending and its outcome is unknown, and the message being readable in its channel means sent. A client treats a send as cancelled only after it gets OK true for its cancel. On invalid: stale generation or invalid: stale replacement, another device has changed the send, so the client reads the address again.
Retention
| Send ended as | Instruction | Status |
|---|---|---|
sent, or cancelled by the relay |
Deleted when the send ends | Readable for status_retention |
failed, missed |
Readable to the author for text_retention after the status is stored, then deleted |
Readable for status_retention |
| Cancelled by the author | The cancel replaces the instruction it cancels, which is deleted. The cancel is readable for status_retention, then deleted |
none |
Deleting an instruction means that the relay no longer stores the instruction's copy of the message in any form.
A relay MUST keep at most max_pending ended instructions for one author in a community. Cancels and the instructions of failed and missed sends count together. When the end of a send would take the author past that number, the relay first deletes the ended instruction whose send ended earliest. Its address stays closed. If it held the text of a failed or missed send, the author loses that text early. If it was a cancel, a complete read then reports that send under rule 3.
So one request can return all of an author's instructions in a community: at most max_pending pending and as many ended. A relay MUST advertise a NIP-11 max_limit of at least twice max_pending, and MUST NOT change either limit in a way that lets those instructions exceed max_limit.
Support
Until this draft has an upstream NIP number, relays MUST NOT list it in NIP-11 supported_nips. A relay advertises send later for the community that a NIP-11 request resolves to, with "buzz-send-later" in supported_extensions and this descriptor:
{
"supported_extensions": ["buzz-send-later"],
"send_later": {
"v": 1,
"accepting": true,
"kinds": [9],
"limitation": {
"max_not_before_delta": 10368000,
"max_pending": 100,
"release_window": 900,
"text_retention": 604800,
"status_retention": 2592000,
"max_content_len": 524288
}
}
}
| Member | Meaning |
|---|---|
v |
Version of this contract. This document defines 1 |
accepting |
true when the relay accepts instructions that hold a message: new sends and replacements. When false it accepts only cancels and reads |
kinds |
The kinds a message may have |
limitation |
The limits in Limits summary, each a positive integer. A relay MUST enforce the limits it advertises |
A relay MUST NOT serve the descriptor without a NIP-11 self key, and MUST NOT change that key while a status signed with it is readable. A relay that hosts several communities MUST serve the descriptor only for a community in which send later is enabled.
A client MUST treat the descriptor as absent in any of these cases:
supported_extensionsdoes not contain"buzz-send-later".- The NIP-11 document has no
self, orselfis not 64 lowercase hex characters. vis not1.v,accepting,kinds,limitationor a limit in Limits summary is missing or has the wrong type.
Without a valid descriptor a client MUST NOT publish kind:30360 and MUST NOT offer send later. A relay that does not implement this NIP may store both kinds as ordinary events that any reader can query.
A client offers send later only while accepting is true, and keeps T and its number of pending sends inside the limits. If the relay stops serving a valid descriptor, the client treats the state of its pending sends as unknown and reads again when the descriptor returns.
Late arrival
A released message carries created_at T but can reach readers up to release_window later. A reader that opens a live subscription or fetches new messages with since SHOULD therefore set it back by at least the relay's created_at tolerance, and discard by id the events it already holds.
That delivers a late message, but a reader that records a channel as read up to a created_at value still counts it as read. This NIP does not remove that limitation. The time or order in which one device received a message is not evidence that the message is unread, and a client MUST NOT substitute it. To count a late message as unread on every device of a user, those devices need shared read state that does not depend on created_at: an order that follows when the relay stored a message, or a complete record of the messages read by id. A client with such read state SHOULD count a late message as unread.
Federated identity
In a community that requires NIP-FI, a send is a deferred action under Deferred actions, because the relay releases it without a session. Each accepted generation is an acceptance of the deferred action, so the relay stores the admission that carried it. That section defines which sends a disconnect command cancels: those of the target key and of every key it owns, accepted under the command's issuer and within its scope, in every community. It also defines when check 12 refuses an instruction. A relay MUST NOT enable send later in such a community unless it implements that section.
Nothing else in NIP-FI ends an accepted send. At release the relay does not contact the issuer, require a recent assertion or evaluate the community's issuer policy again. An issuer that only stops issuing assertions does not stop a pending send.
Security
The author trusts the relay with the signed message, which is a valid event from the moment it is signed. A relay that misbehaves can withhold it, or post it inside the timestamp window around T after a cancel. It cannot forge a message, change one, or post one at another time. Nothing revokes the signed message cryptographically, so a cancel holds only because the relay enforces it.
There is no session at release, so authority to post comes from the author's signatures. A created_at condition in an agent's NIP-OA auth tag is evaluated against T, so an owner's time bound on an agent also bounds how far ahead the agent can send. A NIP-46 remote signer needs no delegation: it signs the message for T and signs the instruction. Signing takes time, so a client that sends now through a remote signer SHOULD expect invalid: not_before in the past and retry with a newly signed message.
A relay SHOULD count each instruction against the author's ordinary rate limit.
The relay stores a pending message in the clear, as it stores a posted one. Someone who can read the relay's storage can therefore read a send before it posts.
Limits summary
The relay advertises these in limitation (Support). Times are in seconds.
| Member | Limit | Recommended |
|---|---|---|
max_not_before_delta |
How far ahead T may be |
10368000 (120 days) |
max_pending |
Pending sends for one author in a community, and ended instructions kept for that author | 100 |
release_window |
How long after T the relay may still release. It MUST exceed 60 and MUST NOT exceed the relay's created_at tolerance for ordinary events |
900 |
text_retention |
How long the instruction of a failed or missed send stays readable |
604800 (7 days) |
status_retention |
How long a status stays readable. It MUST exceed text_retention |
2592000 (30 days) |
max_content_len |
Maximum instruction content, in bytes. It SHOULD fit the largest message the relay accepts live |