Transformations

Try a transformation on a webhook a source received, or on a sample, and see what it would send.

Try a transformation

POST/v1/projects/{project}/transformations/try

Runs a transformation once, the way a delivery would, and returns what it would send. Nothing is saved, and nothing is sent to a destination. Needs the Edit and resend permission.

codestringRequired

JavaScript that defines transform(request), not empty, and at most 64 KB. See Change webhooks before they are sent.

eventIdstring

An event to run it on. Without it, it runs on a sample: a POST with content-type: application/json and the body {"hello":"world"}.

A transformation that fails still answers 200, with the reason in error:

{
  "input": {
    "method": "POST",
    "path": "/",
    "query": "",
    "headers": { "content-type": "application/json" },
    "body": { "reference": "ORD-104233", "amount": 25000 }
  },
  "output": {
    "headers": [{ "name": "x-order-id", "value": "ORD-104233" }],
    "body": "{\"orderId\":\"ORD-104233\",\"amountTzs\":25000}",
    "bodyEncoding": "text"
  },
  "error": null,
  "logs": ["payment ORD-104233"],
  "durationMs": 3
}
inputobject

The request the transformation got.

outputobject or null

What it would send, before the authentication and signing headers are added: headers, each { name, value }, body, and bodyEncoding, text or base64. null when it failed.

errorstring or null

Why it failed, such as a syntax error, a thrown error, a wrong shape, or running out of time or memory. null when it worked.

logsstring[]

The lines it wrote with console.log.

durationMsinteger

How long it ran, in milliseconds. A delivery stops it after 100 ms.

An event the project does not have gets 404. When we cannot run the transformation this time, the answer is 503 with the code unavailable; try again.

Last updated