Transforms API

Transforms modify webhook payloads before delivery using JSONata, JavaScript, Liquid, or XSLT.

Endpoints

MethodPathDescription
GET/api/transformsList transforms
POST/api/transformsCreate transform
GET/api/transforms/{id}Get transform
PATCH/api/transforms/{id}Update transform
DELETE/api/transforms/{id}Delete transform

Transform Object

{
  "id": "tfm_abc123",
  "name": "GitHub to Slack",
  "description": "Format GitHub events for Slack",
  "type": "javascript",
  "code": "function transform(payload) { return { text: payload.action }; }",
  "inputFormat": "json",
  "outputFormat": "json",
  "routeCount": 3,
  "createdAt": "2024-01-01T00:00:00Z",
  "updatedAt": "2024-01-15T10:30:00Z"
}

Transform Types

TypeDescription
jsonataJSONata expression (default)
javascriptJavaScript function
liquidLiquid template
xsltXSLT stylesheet

Input/Output Formats

FormatDescription
jsonJSON (default)
xmlXML
textPlain text

List Transforms

GET /api/transforms

Query Parameters

ParameterTypeDescription
pagenumberPage number (default: 1)
pageSizenumberItems per page (default: 20, max: 100)
searchstringSearch by name
typestringFilter by type: jsonata, javascript, liquid, xslt

Example

curl
curl https://api.hookbase.app/api/transforms \
  -H "Authorization: Bearer whr_your_api_key"

Response

{
  "data": [
    {
      "id": "tfm_abc123",
      "name": "GitHub to Slack",
      "type": "javascript",
      "routeCount": 3,
      "createdAt": "2024-01-01T00:00:00Z"
    }
  ],
  "pagination": {
    "total": 5,
    "page": 1,
    "pageSize": 20
  }
}

Create Transform

POST /api/transforms

Request Body

FieldTypeRequiredDescription
namestringYesDisplay name
codestringYesTransform code
descriptionstringNoOptional description
typestringNoTransform type (default: jsonata)
inputFormatstringNoInput format (default: json)
outputFormatstringNoOutput format (default: json)

Example

curl
curl -X POST https://api.hookbase.app/api/transforms \
  -H "Authorization: Bearer whr_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Extract Fields",
    "type": "jsonata",
    "code": "{ \"event\": action, \"repo\": repository.full_name }",
    "description": "Extract key fields from GitHub webhooks"
  }'

Response

{
  "id": "tfm_new123",
  "name": "Extract Fields",
  "description": "Extract key fields from GitHub webhooks",
  "type": "jsonata",
  "code": "{ \"event\": action, \"repo\": repository.full_name }",
  "inputFormat": "json",
  "outputFormat": "json",
  "routeCount": 0,
  "createdAt": "2024-01-15T10:30:00Z",
  "updatedAt": "2024-01-15T10:30:00Z"
}

Tip

The code is validated on creation. If there are syntax errors, the API returns a 400 response with details about the error.

Get Transform

GET /api/transforms/{id}

Example

curl
curl https://api.hookbase.app/api/transforms/tfm_abc123 \
  -H "Authorization: Bearer whr_your_api_key"

Response

Returns the full transform object.

Update Transform

PATCH /api/transforms/{id}

Request Body

All fields are optional. Only provided fields are updated.

FieldTypeDescription
namestringDisplay name
codestringTransform code
descriptionstringOptional description
typestringTransform type
inputFormatstringInput format
outputFormatstringOutput format

Example

curl
curl -X PATCH https://api.hookbase.app/api/transforms/tfm_abc123 \
  -H "Authorization: Bearer whr_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "{ \"event\": action, \"repo\": repository.full_name, \"sender\": sender.login }"
  }'

Response

Returns the updated transform object.

Delete Transform

DELETE /api/transforms/{id}

Warning

A transform cannot be deleted while it is assigned to active routes. Remove it from all routes first.

Example

curl
curl -X DELETE https://api.hookbase.app/api/transforms/tfm_abc123 \
  -H "Authorization: Bearer whr_your_api_key"

Response

204 No Content

Error Responses

400 Bad Request

Invalid transform code:

{
  "error": "Bad Request",
  "message": "Transform code validation failed: Unexpected token at position 15",
  "code": "INVALID_CODE"
}

404 Not Found

Transform not found:

{
  "error": "Not Found",
  "message": "Transform with ID tfm_xyz not found",
  "code": "RESOURCE_NOT_FOUND"
}

409 Conflict

Transform in use:

{
  "error": "Conflict",
  "message": "Transform is assigned to 3 active routes",
  "code": "RESOURCE_IN_USE"
}