> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apitraffic.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Redactions

> Manage data redaction rules to protect sensitive information

## List Redactions

<api-endpoint method="GET" url="https://api.apitraffic.io/v1/accounts/{accountSid}/redactions" />

Retrieve all redaction rules configured for an account.

### Path Parameters

<ParamField path="accountSid" type="string" required>
  Account identifier (format: `acc_` followed by 27 alphanumeric characters)
</ParamField>

### Headers

<ParamField header="Authorization" type="string" required>
  Bearer token for authentication
</ParamField>

### Response

<ResponseField name="hasMore" type="boolean">
  Indicates if there are more records to paginate through
</ResponseField>

<ResponseField name="records" type="array">
  <Expandable title="Redaction Objects">
    <ResponseField name="sid" type="string">
      Unique redaction rule identifier
    </ResponseField>

    <ResponseField name="accountSid" type="string">
      Account identifier this redaction belongs to
    </ResponseField>

    <ResponseField name="name" type="string">
      Name of the redaction rule
    </ResponseField>

    <ResponseField name="description" type="string">
      Description of what this rule redacts
    </ResponseField>

    <ResponseField name="fieldPath" type="string">
      JSON path to the field to be redacted
    </ResponseField>

    <ResponseField name="redactionType" type="string">
      Type of redaction: `mask`, `remove`, `hash`, `replace`
    </ResponseField>

    <ResponseField name="replacementValue" type="string">
      Value to use when redactionType is `replace` (nullable)
    </ResponseField>

    <ResponseField name="isActive" type="boolean">
      Whether this redaction rule is currently active
    </ResponseField>

    <ResponseField name="createdAt" type="string">
      ISO 8601 timestamp of rule creation
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET "https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/redactions" \
    -H "Authorization: Bearer your-jwt-token"
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/redactions', {
    headers: {
      'Authorization': 'Bearer your-jwt-token'
    }
  });

  const redactions = await response.json();
  console.log(redactions);
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      'https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/redactions',
      headers={'Authorization': 'Bearer your-jwt-token'}
  )

  redactions = response.json()
  print(redactions)
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "hasMore": false,
    "records": [
      {
        "sid": "red_abc123def456ghi789jkl012",
        "accountSid": "acc_abc123def456ghi789jkl012",
        "name": "Password Redaction",
        "description": "Redacts password fields from request bodies",
        "fieldPath": "$.password",
        "redactionType": "mask",
        "replacementValue": null,
        "isActive": true,
        "createdAt": "2023-12-01T10:30:00.000Z"
      },
      {
        "sid": "red_xyz789uvw012rst345abc",
        "accountSid": "acc_abc123def456ghi789jkl012",
        "name": "Credit Card Masking",
        "description": "Masks credit card numbers",
        "fieldPath": "$.payment.cardNumber",
        "redactionType": "mask",
        "replacementValue": null,
        "isActive": true,
        "createdAt": "2023-12-01T11:15:00.000Z"
      }
    ]
  }
  ```
</ResponseExample>

***

## Get Redaction

<api-endpoint method="GET" url="https://api.apitraffic.io/v1/accounts/{accountSid}/redactions/{redactionSid}" />

Retrieve details of a specific redaction rule.

### Path Parameters

<ParamField path="accountSid" type="string" required>
  Account identifier
</ParamField>

<ParamField path="redactionSid" type="string" required>
  Redaction rule identifier
</ParamField>

### Headers

<ParamField header="Authorization" type="string" required>
  Bearer token for authentication
</ParamField>

### Response

Returns a single redaction object with the same structure as described in the List Redactions response.

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET "https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/redactions/red_abc123def456ghi789jkl012" \
    -H "Authorization: Bearer your-jwt-token"
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/redactions/red_abc123def456ghi789jkl012', {
    headers: {
      'Authorization': 'Bearer your-jwt-token'
    }
  });

  const redaction = await response.json();
  console.log(redaction);
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "sid": "red_abc123def456ghi789jkl012",
    "accountSid": "acc_abc123def456ghi789jkl012",
    "name": "Password Redaction",
    "description": "Redacts password fields from request bodies",
    "fieldPath": "$.password",
    "redactionType": "mask",
    "replacementValue": null,
    "isActive": true,
    "createdAt": "2023-12-01T10:30:00.000Z"
  }
  ```
</ResponseExample>

***

## Create Redaction

<api-endpoint method="POST" url="https://api.apitraffic.io/v1/accounts/{accountSid}/redactions" />

Create a new redaction rule to protect sensitive data.

### Path Parameters

<ParamField path="accountSid" type="string" required>
  Account identifier
</ParamField>

### Headers

<ParamField header="Authorization" type="string" required>
  Bearer token for authentication
</ParamField>

### Request Body

<ParamField body="name" type="string" required>
  Name of the redaction rule
</ParamField>

<ParamField body="description" type="string">
  Description of what this rule redacts
</ParamField>

<ParamField body="fieldPath" type="string" required>
  JSON path to the field to be redacted (e.g., `$.password`, `$.user.email`)
</ParamField>

<ParamField body="redactionType" type="string" required>
  Type of redaction: `mask`, `remove`, `hash`, or `replace`
</ParamField>

<ParamField body="replacementValue" type="string">
  Value to use when redactionType is `replace`
</ParamField>

<ParamField body="isActive" type="boolean">
  Whether this redaction rule should be active (default: true)
</ParamField>

### Response

Returns the created redaction object.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/redactions" \
    -H "Authorization: Bearer your-jwt-token" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Email Redaction",
      "description": "Masks email addresses in user data",
      "fieldPath": "$.user.email",
      "redactionType": "mask",
      "isActive": true
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/redactions', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer your-jwt-token',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      name: 'Email Redaction',
      description: 'Masks email addresses in user data',
      fieldPath: '$.user.email',
      redactionType: 'mask',
      isActive: true
    })
  });

  const redaction = await response.json();
  console.log(redaction);
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/redactions',
      headers={
          'Authorization': 'Bearer your-jwt-token',
          'Content-Type': 'application/json'
      },
      json={
          'name': 'Email Redaction',
          'description': 'Masks email addresses in user data',
          'fieldPath': '$.user.email',
          'redactionType': 'mask',
          'isActive': True
      }
  )

  redaction = response.json()
  print(redaction)
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "sid": "red_new789uvw012rst345def",
    "accountSid": "acc_abc123def456ghi789jkl012",
    "name": "Email Redaction",
    "description": "Masks email addresses in user data",
    "fieldPath": "$.user.email",
    "redactionType": "mask",
    "replacementValue": null,
    "isActive": true,
    "createdAt": "2023-12-01T15:45:00.000Z"
  }
  ```
</ResponseExample>

***

## Update Redaction

<api-endpoint method="PUT" url="https://api.apitraffic.io/v1/accounts/{accountSid}/redactions/{redactionSid}" />

Update an existing redaction rule.

### Path Parameters

<ParamField path="accountSid" type="string" required>
  Account identifier
</ParamField>

<ParamField path="redactionSid" type="string" required>
  Redaction rule identifier
</ParamField>

### Headers

<ParamField header="Authorization" type="string" required>
  Bearer token for authentication
</ParamField>

### Request Body

<ParamField body="name" type="string" required>
  Name of the redaction rule
</ParamField>

<ParamField body="description" type="string">
  Description of what this rule redacts
</ParamField>

<ParamField body="fieldPath" type="string" required>
  JSON path to the field to be redacted
</ParamField>

<ParamField body="redactionType" type="string" required>
  Type of redaction: `mask`, `remove`, `hash`, or `replace`
</ParamField>

<ParamField body="replacementValue" type="string">
  Value to use when redactionType is `replace`
</ParamField>

<ParamField body="isActive" type="boolean" required>
  Whether this redaction rule should be active
</ParamField>

### Response

Returns the updated redaction object.

<RequestExample>
  ```bash cURL theme={null}
  curl -X PUT "https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/redactions/red_abc123def456ghi789jkl012" \
    -H "Authorization: Bearer your-jwt-token" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Updated Password Redaction",
      "description": "Redacts all password fields from requests and responses",
      "fieldPath": "$.password",
      "redactionType": "remove",
      "isActive": true
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/redactions/red_abc123def456ghi789jkl012', {
    method: 'PUT',
    headers: {
      'Authorization': 'Bearer your-jwt-token',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      name: 'Updated Password Redaction',
      description: 'Redacts all password fields from requests and responses',
      fieldPath: '$.password',
      redactionType: 'remove',
      isActive: true
    })
  });

  const redaction = await response.json();
  console.log(redaction);
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "sid": "red_abc123def456ghi789jkl012",
    "accountSid": "acc_abc123def456ghi789jkl012",
    "name": "Updated Password Redaction",
    "description": "Redacts all password fields from requests and responses",
    "fieldPath": "$.password",
    "redactionType": "remove",
    "replacementValue": null,
    "isActive": true,
    "createdAt": "2023-12-01T10:30:00.000Z"
  }
  ```
</ResponseExample>

***

## Delete Redaction

<api-endpoint method="DELETE" url="https://api.apitraffic.io/v1/accounts/{accountSid}/redactions/{redactionSid}" />

Delete a redaction rule.

<Warning>
  Deleting a redaction rule will not affect previously redacted data, but new requests will no longer have this redaction applied.
</Warning>

### Path Parameters

<ParamField path="accountSid" type="string" required>
  Account identifier
</ParamField>

<ParamField path="redactionSid" type="string" required>
  Redaction rule identifier
</ParamField>

### Headers

<ParamField header="Authorization" type="string" required>
  Bearer token for authentication
</ParamField>

### Response

<ResponseField name="sid" type="string">
  ID of the deleted redaction rule
</ResponseField>

<ResponseField name="deleted" type="boolean">
  Flag indicating the redaction rule was successfully deleted
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X DELETE "https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/redactions/red_abc123def456ghi789jkl012" \
    -H "Authorization: Bearer your-jwt-token"
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/redactions/red_abc123def456ghi789jkl012', {
    method: 'DELETE',
    headers: {
      'Authorization': 'Bearer your-jwt-token'
    }
  });

  const result = await response.json();
  console.log(result);
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "sid": "red_abc123def456ghi789jkl012",
    "deleted": true
  }
  ```
</ResponseExample>

***

## Redaction Types

### Mask

Replaces characters with asterisks while preserving format:

* `john@example.com` → `j***@*******.com`
* `4111111111111111` → `4***********1111`

### Remove

Completely removes the field from the data:

* `{"password": "secret123"}` → `{}`

### Hash

Replaces the value with a SHA-256 hash:

* `"secret123"` → `"a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3"`

### Replace

Replaces the value with a specified replacement:

* `"secret123"` → `"[REDACTED]"` (when replacementValue is `"[REDACTED]"`)

## JSON Path Examples

<CodeGroup>
  ```json Simple Field theme={null}
  {
    "password": "secret123"
  }
  // JSON Path: $.password
  ```

  ```json Nested Object theme={null}
  {
    "user": {
      "email": "john@example.com"
    }
  }
  // JSON Path: $.user.email
  ```

  ```json Array Element theme={null}
  {
    "users": [
      {"email": "john@example.com"},
      {"email": "jane@example.com"}
    ]
  }
  // JSON Path: $.users[*].email
  ```

  ```json Multiple Levels theme={null}
  {
    "order": {
      "payment": {
        "cardNumber": "4111111111111111"
      }
    }
  }
  // JSON Path: $.order.payment.cardNumber
  ```
</CodeGroup>
