Transforms API
Transforms modify webhook payloads before delivery using JSONata, JavaScript, Liquid, or XSLT.
Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /api/transforms | List transforms |
| POST | /api/transforms | Create 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
| Type | Description |
|---|---|
jsonata | JSONata expression (default) |
javascript | JavaScript function |
liquid | Liquid template |
xslt | XSLT stylesheet |
Input/Output Formats
| Format | Description |
|---|---|
json | JSON (default) |
xml | XML |
text | Plain text |
List Transforms
GET /api/transformsQuery Parameters
| Parameter | Type | Description |
|---|---|---|
| page | number | Page number (default: 1) |
| pageSize | number | Items per page (default: 20, max: 100) |
| search | string | Search by name |
| type | string | Filter by type: jsonata, javascript, liquid, xslt |
Example
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/transformsRequest Body
| Field | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Display name |
| code | string | Yes | Transform code |
| description | string | No | Optional description |
| type | string | No | Transform type (default: jsonata) |
| inputFormat | string | No | Input format (default: json) |
| outputFormat | string | No | Output format (default: json) |
Example
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 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.
| Field | Type | Description |
|---|---|---|
| name | string | Display name |
| code | string | Transform code |
| description | string | Optional description |
| type | string | Transform type |
| inputFormat | string | Input format |
| outputFormat | string | Output format |
Example
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 -X DELETE https://api.hookbase.app/api/transforms/tfm_abc123 \
-H "Authorization: Bearer whr_your_api_key"Response
204 No ContentError 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"
}Related
- Transforms Guide — Types, examples, and best practices
- Routes API — Assign transforms to routes