Skip to content
PayloadPuffin.
Join the waitlist

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

  • transformId string Required

    A transform ID, starting with tfm_.

Body

  • code string Optional

    The code to run, such as an editor’s unsaved text. Omitted: the saved draft runs, or the pinned managed transform.

    1 to 16384 characters

  • event object Optional

    The sample event a destination transform runs on. Required for one.

    • type string Required

      The event type given to the code as type.

      1 to 64 characters

    • payload unknown Required

      A sample event payload, any JSON value, given to the code as payload. It shares the 65,536-byte request body with the code.

  • request object Optional

    The sample request a source transform runs on. Required for one.

    • method string Required

      The method of the sample request.

      Allowed values: "POST", "GET", "PUT", "PATCH", "DELETE"

    • contentType string Required

      The content type of the sample request.

      At most 256 characters

    • headers object[] Required

      Other headers of the sample request.

      At most 50 items

      Show child parametersHide child parameters
      • name string Required

        Header name.

        1 to 256 characters

      • value string Required

        Header value.

        At most 8192 characters

    • body string Required

      The body of the sample request, as text.

  • sourceId string Optional

    For a source transform: run with this source’s default type and channels and its URL. Omitted: no default type or channels.

Returns

200

The command completed.

  • data object Required

    What the code would send or build, or why it would fail.

    • status string Required

      succeeded: 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"

    • delivery object | null Required

      What a delivery would send. Present exactly when a destination transform succeeded.

    • event object | null Required

      The event the code builds. Present exactly when a source transform succeeded.

    • error string | null Required

      Why the run did not succeed. Present exactly when status is not succeeded.

    • budget object Required

      The 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
      • limit integer Required

        Sandbox previews this app may run per UTC day.

      • remaining integer Required

        Previews left today, after this one.

      • resetsAt string (date-time) Required

        The next UTC midnight, when the count starts over.

Example

Request
curl -X POST "https://api.payloadpuffin.com/v1/transforms/$TRANSFORMID/preview" \
  -H "Authorization: Bearer $PAYLOADPUFFIN_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{}'
Response 200
{
  "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.

  • 4XX application/problem+json

    The request was rejected.