---
title: Create a response header transform rule via API · Cloudflare Rules docs
description: Use the Rulesets API to create Response Header Transform Rules via API. Refer to the Rules examples gallery for common use cases.
source_url:
  html: https://kate-fixes-httprbi.preview.developers.cloudflare.com/rules/transform/response-header-modification/create-api/index.md
  md: https://kate-fixes-httprbi.preview.developers.cloudflare.com/rules/transform/response-header-modification/create-api/
---

Use the [Rulesets API](https://developers.cloudflare.com/ruleset-engine/rulesets-api/) to create Response Header Transform Rules via API. Refer to the [Rules examples gallery](https://developers.cloudflare.com/rules/transform/examples/?operation=Response+modification) for common use cases.

If you are using Terraform, refer to [Transform Rules configuration using Terraform](https://developers.cloudflare.com/terraform/additional-configurations/transform-rules/#create-a-response-header-transform-rule).

## Basic rule settings

When creating a response header transform rule via API, make sure you:

* Set the rule action to `rewrite`.
* Define the [header modification parameters](https://developers.cloudflare.com/rules/transform/request-header-modification/reference/parameters/) in the `action_parameters` field according to the operation to perform (set, add, or remove header).
* Deploy the rule to the `http_response_headers_transform` phase at the zone level.

## Procedure

Follow this workflow to create a response header transform rule for a given zone via API:

1. Use the [List zone rulesets](https://developers.cloudflare.com/api/resources/rulesets/methods/list/) operation to check if there is already a ruleset for the `http_response_headers_transform` phase at the zone level.

2. If the phase ruleset does not exist, create it using the [Create a zone ruleset](https://developers.cloudflare.com/api/resources/rulesets/methods/create/) operation. In the new ruleset properties, set the following values:

   * **kind**: `zone`
   * **phase**: `http_response_headers_transform`

3. Use the [Update a zone ruleset](https://developers.cloudflare.com/api/resources/rulesets/methods/update/) operation to add a response header transform rule to the list of ruleset rules. Alternatively, include the rule in the [Create a zone ruleset](https://developers.cloudflare.com/api/resources/rulesets/methods/create/) request mentioned in the previous step.

Make sure your API token has the [required permissions](#required-api-token-permissions) to perform the API operations.

## Example requests

***

## Required API token permissions

The API token used in API requests to manage Response Header Transform Rules must have at least the following permissions:

* *Transform Rules* > *Edit*
* *Account Rulesets* > *Read*
