RequestRocketRequestRocketDocs
API ReferenceCore API

Transforms API

Manage request and response transforms for proxies

Transforms API

Use the Core API to create, update, list, retrieve, and delete proxy request and response transforms.

Transforms are child resources of a proxy:

  • Request transforms run before RequestRocket sends the request to the target.
  • Response transforms run after payload filters and before the response is returned or recorded.

Core API requests use a user token in the raw Authorization header. Do not prefix the token with Bearer.

Endpoints

Request Transforms

MethodEndpointDescription
GET/api/clients/{clientId}/proxies/{proxyId}/request-transformsList request transforms for a proxy
POST/api/clients/{clientId}/proxies/{proxyId}/request-transformsCreate a request transform
GET/api/clients/{clientId}/proxies/{proxyId}/request-transforms/{transformId}Get a request transform with code
PUT/api/clients/{clientId}/proxies/{proxyId}/request-transforms/{transformId}Update a request transform
DELETE/api/clients/{clientId}/proxies/{proxyId}/request-transforms/{transformId}Delete a request transform

Response Transforms

MethodEndpointDescription
GET/api/clients/{clientId}/proxies/{proxyId}/response-transformsList response transforms for a proxy
POST/api/clients/{clientId}/proxies/{proxyId}/response-transformsCreate a response transform
GET/api/clients/{clientId}/proxies/{proxyId}/response-transforms/{transformId}Get a response transform with code
PUT/api/clients/{clientId}/proxies/{proxyId}/response-transforms/{transformId}Update a response transform
DELETE/api/clients/{clientId}/proxies/{proxyId}/response-transforms/{transformId}Delete a response transform

Shared Fields

FieldTypeRequired On CreateDescription
transformModestringYesall or conditional
effectstringConditional useinclude or exclude when transformMode is conditional
transformActivebooleanYesWhether the transform can run
methodsstring arrayNoHTTP methods to match
pathobjectNoPath predicate
queryarrayNoQuery predicates
headersarrayNoRequest header predicates
bodyarrayNoRequest body predicates
tokenarrayNoJWT claim predicates
variablesarrayNoVariables for predicate interpolation
prioritynumberNoHigher priority wins when multiple transforms match
notesstringNoInternal notes
codestringYesTypeScript or JavaScript transform code, maximum 512 KB

Response transforms also support:

FieldTypeDescription
responseHeadersarrayResponse header predicates
responseBodyarrayResponse body predicates
responseStatusarrayResponse status predicates

Code Requirements

code must contain a callable default export.

Request transform minimum:

export default async function transform(proxyContext, proxyRequest) {
  return proxyRequest;
}

Response transform minimum:

export default async function transform(proxyContext, proxyRequest, targetResponse) {
  return targetResponse;
}

The API rejects code that has no default export, uses imports or require, or references unsupported sandbox APIs such as process, fetch, globalThis, eval, or Function.

Create Request Transform

Request

POST /api/clients/{clientId}/proxies/{proxyId}/request-transforms HTTP/1.1
Host: api.requestrocket.com
Authorization: {user_token}
Content-Type: application/json

{
  "transformMode": "all",
  "transformActive": true,
  "priority": 100,
  "notes": "Add source header for target API",
  "code": "export default async function transform(proxyContext, proxyRequest) { return { ...proxyRequest, headers: { ...proxyRequest.headers, \"x-source-system\": \"requestrocket\" } }; }"
}

Response

{
  "requestTransforms": [
    {
      "pKey": "proxy_789",
      "sKey": "550e8400-e29b-41d4-a716-446655440000",
      "clientId": "client_456",
      "userId": "user_123",
      "parentId": "proxy_789",
      "transformRegion": "ap-southeast-2",
      "transformMode": "all",
      "effect": null,
      "transformActive": true,
      "methods": null,
      "path": null,
      "query": null,
      "headers": null,
      "body": null,
      "token": null,
      "variables": null,
      "priority": 100,
      "notes": "Add source header for target API",
      "createdAt": "2026-07-01T00:00:00.000Z",
      "updatedAt": "2026-07-01T00:00:00.000Z",
      "code": "export default async function transform(proxyContext, proxyRequest) { return { ...proxyRequest, headers: { ...proxyRequest.headers, \"x-source-system\": \"requestrocket\" } }; }"
    }
  ],
  "message": "Success"
}

Example

curl -X POST "https://api.requestrocket.com/api/clients/${CLIENT_ID}/proxies/${PROXY_ID}/request-transforms" \
  -H "Authorization: ${USER_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
    "transformMode": "all",
    "transformActive": true,
    "priority": 100,
    "code": "export default async function transform(proxyContext, proxyRequest) { return proxyRequest; }"
  }'
const response = await fetch(
  `https://api.requestrocket.com/api/clients/${clientId}/proxies/${proxyId}/request-transforms`,
  {
    method: 'POST',
    headers: {
      Authorization: process.env.USER_TOKEN,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      transformMode: 'all',
      transformActive: true,
      priority: 100,
      code: 'export default async function transform(proxyContext, proxyRequest) { return proxyRequest; }'
    })
  }
);

const data = await response.json();
console.log(data.requestTransforms[0]);

Create Response Transform

Request

POST /api/clients/{clientId}/proxies/{proxyId}/response-transforms HTTP/1.1
Host: api.requestrocket.com
Authorization: {user_token}
Content-Type: application/json

{
  "transformMode": "conditional",
  "effect": "include",
  "transformActive": true,
  "responseStatus": [
    {
      "operator": "equals",
      "value": 200
    }
  ],
  "priority": 100,
  "notes": "Normalize successful customer responses",
  "code": "export default async function transform(proxyContext, proxyRequest, targetResponse) { return { ...targetResponse, data: { id: targetResponse.data?.customer_id, name: targetResponse.data?.display_name } }; }"
}

Response

{
  "responseTransforms": [
    {
      "pKey": "proxy_789",
      "sKey": "550e8400-e29b-41d4-a716-446655440001",
      "clientId": "client_456",
      "userId": "user_123",
      "parentId": "proxy_789",
      "transformRegion": "ap-southeast-2",
      "transformMode": "conditional",
      "effect": "include",
      "transformActive": true,
      "methods": null,
      "path": null,
      "query": null,
      "headers": null,
      "body": null,
      "token": null,
      "responseHeaders": null,
      "responseBody": null,
      "responseStatus": [
        {
          "operator": "equals",
          "value": 200
        }
      ],
      "variables": null,
      "priority": 100,
      "notes": "Normalize successful customer responses",
      "createdAt": "2026-07-01T00:00:00.000Z",
      "updatedAt": "2026-07-01T00:00:00.000Z",
      "code": "export default async function transform(proxyContext, proxyRequest, targetResponse) { return { ...targetResponse, data: { id: targetResponse.data?.customer_id, name: targetResponse.data?.display_name } }; }"
    }
  ],
  "message": "Success"
}

responseStatus, responseHeaders, and responseBody only apply to response transforms. Request transforms are matched before the target request is sent.

List Transforms

GET /api/clients/{clientId}/proxies/{proxyId}/request-transforms HTTP/1.1
Host: api.requestrocket.com
Authorization: {user_token}

List responses include transform metadata. Use the single-resource GET endpoint when you need the stored code.

{
  "requestTransforms": [
    {
      "pKey": "proxy_789",
      "sKey": "550e8400-e29b-41d4-a716-446655440000",
      "transformMode": "all",
      "transformActive": true,
      "priority": 100,
      "notes": "Add source header for target API"
    }
  ],
  "message": "Success"
}

Get Transform

GET /api/clients/{clientId}/proxies/{proxyId}/request-transforms/{transformId} HTTP/1.1
Host: api.requestrocket.com
Authorization: {user_token}

Single-transform responses include code.

Update Transform

Update accepts partial fields. Include code only when changing the transform code.

PUT /api/clients/{clientId}/proxies/{proxyId}/response-transforms/{transformId} HTTP/1.1
Host: api.requestrocket.com
Authorization: {user_token}
Content-Type: application/json

{
  "transformActive": false,
  "notes": "Temporarily disabled while target payload changes"
}

Successful updates return the updated transform, including the current stored code.

Delete Transform

DELETE /api/clients/{clientId}/proxies/{proxyId}/request-transforms/{transformId} HTTP/1.1
Host: api.requestrocket.com
Authorization: {user_token}

Delete removes the transform metadata and stored code. Deletion takes effect immediately.

Validation Errors

Create and update requests return 400 when the input fails schema validation or code validation.

Example code validation response:

{
  "message": "Transform code failed validation",
  "errors": [
    "request transform must export a default function or callable expression",
    "Imports are not supported in transforms"
  ]
}

Next Steps

On this page