Copyright © 2016 W3C® (MIT, ERCIM, Keio, Beihang). W3C liability, trademark and document use rules apply.
Webmention is a simple way to notify any URL when you link to it on your site. From the receiver's perspective, it's a way to request notifications when other sites link to it.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
This document was published by the Social Web Working Group as a First Public Working Draft. This document is intended to become a W3C Recommendation. If you wish to make comments regarding this document, please send them to public-socialweb@w3.org (subscribe, archives). All comments are welcome.
Publication as a First Public Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
This document is governed by the 1 September 2015 W3C Process Document.
At a basic level, a webmention is a notification that one URL links to another.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119].
This section is non-normative.
A typical Webmention flow is as follows:
This section is non-normative.
source
set to Barnaby's post's permalinktarget
set to Aaron's post's permalink.target
in the webmention is a valid permalink on Aaron's blog (if not, processing stops)source
(when retrieved, after following redirects [FETCH]) in the webmention contains a hyperlink to the target
(if not, processing stops)The sender MUST fetch the target URL and check for an HTTP Link header [RFC5988]
with rel="webmention"
, or a <link>
or
<a>
element with rel="webmention"
. If more than
one of these is present, the first HTTP Link header takes precedence,
followed by the first <link>
element, and finally
the first <a>
element. Clients MUST support all
three options and fall back in this order.
The endpoint MAY be a relative
URL, in which case the sender MUST resolve it relative to the
target
URL according to the [URL] specification.
Senders MAY initially make an HTTP HEAD request [RFC2616] to check for the Link header before making a GET request.
This specification uses the link rel registry as defined by [HTML5] for both HTML and HTTP link relations.
GET /post-by-aaron HTTP/1.1 Host: aaronpk.example HTTP/1.1 200 OK Link: <http://aaronpk.example/webmention-endpoint>; rel="webmention" <html> <head> ... <link href="http://aaronpk.example/webmention-endpoint" rel="webmention" /> ... </head> <body> .... <a href="http://aaronpk.example/webmention-endpoint" rel="webmention">webmention</a> ... </body> </html>
The sender MUST post x-www-form-urlencoded [HTML5] source
and
target
parameters to the webmention endpoint, where
source
is the URL of the sender's page containing a link,
and target
is the URL of the page being linked to.
The webmention endpoint will validate and process the request, and
return an HTTP status code [RFC2616]. Most often, 202 Accepted
or 201 Created
will be returned, indicating that the
request is queued and being processed asynchronously to prevent
DoS attacks. If the response code is 201, the Location
header will include a URL that can be used to monitor the
status of the request.
Any 2xx
response code MUST be considered a success.
POST /webmention-endpoint HTTP/1.1 Host: aaronpk.example Content-Type: application/x-www-form-urlencoded source=https://waterpigs.example/post-by-barnaby& target=https://aaronpk.example/post-by-aaron HTTP/1.1 202 Accepted
Upon receipt of a POST request containing the source
and
target
parameters, the receiver SHOULD queue and process
the request asynchronously to prevent DoS attacks. There are three
possible responses to the request, depending on how the receiver
processes it.
If the receiver creates a status page which the sender can use to
check the status, the receiver MUST reply with an HTTP 201 Created
response with a Location
header pointing to the status
URL. The response body MAY contain content, in which case a human
readable response is recommended.
HTTP/1.1 201 Created Location: http://aaronpk.example/webmention/DEhB9Jme Content-type: text/plain The webmention is being processed. You can check on its status here: http://aaronpk.example/webmention/DEhB9Jme
If the receiver processes the request asynchronously but does not
return a status URL, the receiver MUST reply with an HTTP 202 Accepted
response. The response body MAY contain content, in which case a
human readable response is recommended.
HTTP/1.1 202 Accepted Content-type: text/plain The webmention is being processed
If the receiver chooses to process the request and perform the
verification step synchronously (not recommended), it MUST respond
with a 200 OK
status on success.
The receiver MUST check that source and target are valid URLs [URL] and are of schemes that are supported by the receiver. (Most commonly this means checking that the source and target schemes are http or https).
The receiver SHOULD check that target is a valid resource that it can accept webmentions for. This check SHOULD happen synchronously to reject invalid webmentions before more in-depth verification begins.
Webmention verification SHOULD be handled asynchronously to prevent DoS attacks.
If the receiver is going to use the webmention in some way, (displaying it as a comment on a post, incrementing a "like" counter, notifying the author of a post), then it MUST perform an HTTP GET request on source, and follow any HTTP redirects (up to a self-imposed limit such as 20) to confirm that it actually links to target.
The receiver SHOULD use per-media-type rules to determine whether
the source document links to the target URL. For example, in an
[HTML5] document, the receiver should look for <a href="*">
,
<img href="*">
, <video src="*">
and other similar links. In a [JSON] document, the receiver should
look for properties whose values are an exact match for the URL.
If the document is plain text, the receiver should look for the URL
by searching for the string. Other content types may be handled at
the implementer's discretion. The source document MUST have an exact
match of the target URL provided in order for it to be considered a
valid link.
At this point, the receiver MAY publish content from this webmention on the target page or other pages, along with any other data it picks up from the source. For example, the receiver may display the contents of the source as a comment on the post.
If the webmention was not successful because of something the
sender did, it MUST return a 400 Bad Request
status code and MAY include a description of the error in the response body.
Possible sender-related errors that can be returned synchronously before making a GET request to the source:
target
URL not found.target
URL does not accept webmentions.source
URL was malformed or is not a supported URL scheme (e.g. a mailto: link)Possible sender-related errors that can occur after fetching the contents of the source URL:
source
URL not found.source
URL does not contain a link to the target
URL.If the webmention was not successful because of an error on
the receiver's server, it SHOULD return a 500 Internal Server Error
status code and MAY include a description of the error in the response body.
If receiver had received a webmention in the past with the same
source
and target
then,
source
for the existing webmention.
410 Gone
status code on step 2 (performing a GET request on source), or received a 200 OK
status code and does not find a link to target
on source
, it SHOULD delete the existing webmention.source
and target
with no content changes should not show as multiple replies.The Webmention protocol relies on the sender making a GET (or HEAD) request to discover the receiver's endpoint, followed by the receiver making a GET request to the sender's web page to verify the link. This means a sender can cause a receiver to make GET requests to arbitrary URLs, opening up a potential DoS vector.
Receivers SHOULD place limits on the amount of data and time they spend fetching unverified source URLs. For example, if a source URL doesn't respond within 5 seconds, it can treat that as a failure. Similarly, the receiver can fetch only the first 1mb of the page, since any reasonably HTML or JSON page will be smaller than that.
This section is non-normative.
The following Webmention Extension Specifications have 2+ interoperable implementations live on the web and are thus listed here:
The [Vouch] protocol is an anti-spam extension to Webmention.
The [Salmention] protocol is an extension to Webmention to propagate comments and other interactions upstream.
This section is non-normative.
This section is non-normative.
You can find a list of articles about Webmention on the IndieWebCamp wiki.
This section is non-normative.
http_rels($h)
& head_http_rels($url)
- HTTP header string parser for RFC5988 Link: rels (including X-Pingback
) & function to curl a HEAD request and parse it all in one.The editor wishes to thank Sandeep Shetty for contributing the original draft of the webmention specification.
Additionally, the editor wishes to thank the IndieWebCamp community and other implementers for their support, encouragement and enthusiasm, including but not limited to: Amy Guy, Benjamin Roberts, Ben Werdmüller, Dave Wilkinson, Rob Sanderson, and Tantek Çelik.