WebMention

View the Project on GitHub converspace/webmention

A modern alternative to Pingback.

Protocol Flow

Sender discovers Receiver Endpoint

GET /bob/post/2 HTTP/1.1
Host: bobs.host
HTTP/1.1 200 OK
Link: <http://bobs.host/webmention-endpoint>; rel="http://webmention.org/"

<html>
...
<link href="http://bobs.host/webmention-endpoint" rel="http://webmention.org/" />
...

Sender Notifies Receiver

POST /webmention-endpoint HTTP/1.1
Host: bobs.host
Content-Type: application/x-www-url-form-encoded

source=http://alices.host/alice/post/42&
target=http://bobs.host/bob/post/2
HTTP/1.1 202 Accepted

Verification

bobs.host SHOULD check that target is a valid resource belonging to it and then perform a GET on source and confirm that it actually links to target.

Note: Might look for rel="in-reply-to", or just the link itself somewhere on the page.

Response

Success

If the WebMention request was successful, the server MUST reply with an HTTP 202 Accepted response code. The body of the response is left undefined, but is recommended to return a message indicating the pingback was successful and should respect the content-type of the Accept header. If no Accept header is present, an HTML success body may be returned. It is also valid to not send any body in the response.

For example, typical responses may look like the following:

HTML

POST /webmention-endpoint HTTP/1.1
Host: bobs.host
Content-Type: application/x-www-url-form-encoded

source=http://alices.host/alice/post/42&
target=http://bobs.host/bob/post/2
HTTP/1.1 202 Accepted
Content-Type: text/html

<!DOCTYPE html>
<html>
  <head>
    <title>WebMention</title>
  </head>
  <body>
    <p>WebMention was successful</p>
  </body>
</html>

JSON

POST /webmention-endpoint HTTP/1.1
Host: bobs.host
Content-Type: application/x-www-url-form-encoded
Accept: application/json

source=http://alices.host/alice/post/42&
target=http://bobs.host/bob/post/2
HTTP/1.1 202 Accepted
Content-Type: application/json

{
  "result": "WebMention was successful"
}

Errors

In addition to the standard HTTP status codes that may be returned for things like malformed requests, WebMention defines several error cases that must be handled.

All errors below MUST be returned with an HTTP 400 Bad Request response code.

The format of the error body should respect the content-type in the Accept header. If no Accept header is present, it is acceptable to return an HTML body with a description of the error.

HTML

POST /webmention-endpoint HTTP/1.1
Host: bobs.host
Content-Type: application/x-www-url-form-encoded

source=http://alices.host/alice/post/42&
target=http://bobs.host/bob/post/2
HTTP/1.1 400 Bad Request
Content-Type: text/html

<!DOCTYPE html>
<html>
  <head>
    <title>WebMention Error</title>
  </head>
  <body>
    <h2>no_link_found</h2>
    <p>The source URI does not contain a link to the target URI</p>
  </body>
</html>

JSON

POST /webmention-endpoint HTTP/1.1
Host: bobs.host
Content-Type: application/x-www-url-form-encoded
Accept: application/json

source=http://alices.host/alice/post/42&
target=http://bobs.host/bob/post/2
HTTP/1.1 400 Bad Request

{
  "error": "no_link_found",
  "error_description": "The source URI does not contain a link to the target URI"
}

Preventing Spam and Abuse

See also

Let's collaborate

Feel free to file an issue if you have feedback/questions/suggestions.