Skip to Content

Webhook payload

The webhook target sends one POST per release with the whole bundle's text as JSON. Use it to hand a release to an automation service or to your own endpoint.

Settings

SettingDefaultWhat
urlWhere to post. An https URL with no credentials in it; plain http only to localhost, 127.0.0.1, or [::1].
url_envName of the env var holding the URL, for hook URLs that are secrets themselves. Set exactly one of url and url_env.
secret_envName of the env var holding the signing secret. With none, the request is sent unsigned.
imagesnonenone, url, or base64.
image_base_urlRequired for images: url. Each image's URL is this with the image's bundle path added to its path; a query string on it is kept. The target does not upload images; serve them yourself.
targets:
  - plugin: webhook
    url_env: PEBBLE_HOOK_URL
    secret_env: PEBBLE_HOOK_SECRET

Request

HeaderValue
Content-Typeapplication/json
Idempotency-Keyjustshipped-<app>-<version>, each part URL-encoded. The same on every delivery of one app and version: drop or replace repeats.
X-Justshipped-Signaturesha256=<hex>: HMAC-SHA256 of the raw request body, keyed with the secret. Sent only when secret_env is set.

Any 2xx answer counts as delivered. Anything else fails the target, and so does a redirect: the body is never sent on to a URL that was not configured.

Body

The schema is WebhookPayload in @justshipped/sdk, also published as JSON Schema at @justshipped/sdk/schemas/webhook-payload.schema.json.

FieldWhat
schemaVersion1
event"release"
app, versionAs in release.json
idempotencyKeyThe Idempotency-Key header's value
releaserelease.json in full (see release.schema.json)
files[{ path, text }]: every text output release.outputs names (changelog, post, social posts, store text, feeds, email, developer notes)
images[{ path, kind, itemId?, url? , base64?, mediaType? }]. Empty with images: none; url set with images: url; base64 and mediaType set with images: base64.

release includes every change, internal ones too. Send it only to a receiver you would trust with the bundle zip. Files under internal/ (the support memo) are never sent: neither in files nor named in release, whose outputs, file hashes and text edits leave them out.

{
  "schemaVersion": 1,
  "event": "release",
  "app": "Pebble",
  "version": "1.4.0",
  "idempotencyKey": "justshipped-Pebble-1.4.0",
  "release": { "schemaVersion": 1, "app": "Pebble", "version": "1.4.0", "...": "..." },
  "files": [
    { "path": "changelog.md", "text": "## New\n\n- Streak reminders.\n" },
    { "path": "social/x.md", "text": "Pebble 1.4.0 is out.\n" }
  ],
  "images": [
    {
      "path": "images/card.png",
      "kind": "template",
      "url": "https://pebble.example.com/releases/1.4.0/images/card.png"
    }
  ]
}

Verifying the signature

Compute the HMAC over the raw body bytes as received, before any JSON parsing, and compare in constant time. Re-serializing the parsed JSON gives different bytes and a different signature.

Node:

import { createHmac, timingSafeEqual } from "node:crypto";

function verify(rawBody /* Buffer */, header, secret) {
  const expected = Buffer.from(`sha256=${createHmac("sha256", secret).update(rawBody).digest("hex")}`);
  const given = Buffer.from(header ?? "");
  return given.length === expected.length && timingSafeEqual(given, expected);
}

Python:

import hashlib
import hmac

def verify(raw_body: bytes, header: str, secret: str) -> bool:
    expected = "sha256=" + hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(header or "", expected)

To check an implementation: the key Jefe and the body what do ya want for nothing? give sha256=5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843.

Edit on GitHub

On this page