Preview a transform
POST/v1/transforms/{transformId}/previewpreview
Run the saved draft, or code sent with the request, on a sample in the transform’s preview sandbox: an event for a destination transform, a request for a source transform. A run that executed answers 200 whatever its outcome. Nothing is saved, published, delivered or counted as a transform run, and the code shares no state with live runs. Each preview spends one of the app’s daily sandbox previews (50 per UTC day); past the budget it answers 429 with Retry-After and does not run. Refused with 409 when no code is sent and there is nothing to run.
Path parameters
transformIdstring RequiredA transform ID, starting with tfm_.
Body
codestring OptionalThe code to run, such as an editor’s unsaved text. Omitted: the saved draft runs, or the pinned managed transform.
1 to 16384 characters
eventobject OptionalThe sample event a destination transform runs on. Required for one.
typestring RequiredThe event type given to the code as
type.1 to 64 characters
payloadunknown RequiredA sample event payload, any JSON value, given to the code as
payload. It shares the 65,536-byte request body with the code.
requestobject OptionalThe sample request a source transform runs on. Required for one.
methodstring RequiredThe method of the sample request.
Allowed values: "POST", "GET", "PUT", "PATCH", "DELETE"
contentTypestring RequiredThe content type of the sample request.
At most 256 characters
headersobject[] RequiredOther headers of the sample request.
At most 50 items
Show child parametersHide child parameters
namestring RequiredHeader name.
1 to 256 characters
valuestring RequiredHeader value.
At most 8192 characters
bodystring RequiredThe body of the sample request, as text.
sourceIdstring OptionalFor a source transform: run with this source’s default type and channels and its URL. Omitted: no default type or channels.
Returns
The command completed.200
dataobject RequiredWhat the code would send or build, or why it would fail.
statusstring Requiredsucceeded: the code returned what its kind returns. failed: it threw, returned something else, or ran past 5 seconds. output_too_large: its output is over 262,144 bytes.
Allowed values: "succeeded", "failed", "output_too_large"
deliveryobject | null RequiredWhat a delivery would send. Present exactly when a destination transform succeeded.
eventobject | null RequiredThe event the code builds. Present exactly when a source transform succeeded.
errorstring | null RequiredWhy the run did not succeed. Present exactly when status is not succeeded.
budgetobject RequiredThe app daily budget of sandbox previews. Every preview that reaches the sandbox spends one, whatever its outcome and whether or not the code is new.
Show child attributesHide child attributes
limitinteger RequiredSandbox previews this app may run per UTC day.
remaininginteger RequiredPreviews left today, after this one.
resetsAtstring (date-time) RequiredThe next UTC midnight, when the count starts over.
Example
curl -X POST "https://api.payloadpuffin.com/v1/transforms/$TRANSFORMID/preview" \
-H "Authorization: Bearer $PAYLOADPUFFIN_API_KEY" \
-H 'Content-Type: application/json' \
-d '{}'{
"data": {
"status": "succeeded",
"delivery": {
"body": "body",
"headers": [
{
"name": "name",
"value": "value"
}
]
},
"event": {
"type": "type",
"channels": [
"channels"
],
"payload": "payload"
},
"error": "error",
"budget": {
"limit": 0,
"remaining": 0,
"resetsAt": "resetsAt"
}
}
}Errors
Errors use application/problem+json. The code member is stable; branch on it rather than on title or detail.
4XXapplication/problem+jsonThe request was rejected.