# Data Masking API

> Data Masking redacts sensitive data like emails, phone numbers, payment cards, IP addresses, and dates using placeholder tokens. It returns the sanitized string and detection counts for each pattern found.

**Endpoint:** `POST https://api.apiverve.com/v1/datamasking`  
**Category:** Text Processing  
**Cost:** 10 credits per call  
**Canonical page:** https://apiverve.com/marketplace/datamasking

## Overview

Data Masking works by scanning text for sensitive data patterns and replacing them with masked placeholders. Returns both the masked text and detection statistics for multiple data types.

## Authentication

Every call carries your key in an `x-api-key` header. The same key works across the whole
APIVerve catalog — there are no per-API subscriptions. Responses always use the same three
top-level keys: `status`, `error`, and `data`.

## Example request

```bash
curl -X POST "https://api.apiverve.com/v1/datamasking" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"Contact John Doe at john.doe@email.com or call 555-123-4567. His SSN is 123-45-6789.","types":"value"}'
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `text` | string | Yes | The text containing sensitive data to mask. length 0-50000 |
| `types` | array | No | Array of data types to mask (default: all types). Allowed values: email, phone, ssn, credit_card, ip_address (IPv4 and IPv6), url, date; any other value returns a 400. A comma-separated string such as "email,phone" is also accepted. default ["email","phone","ssn","credit_card","ip_address","url","date"]. Premium field |

## Response fields

- `masked` — string · Text with sensitive data replaced by masking placeholders
- `detected` — object · Object containing count statistics for each detected data type
  - `detected.email` — number · Number of email addresses detected and masked in text
  - `detected.phone` — number · Number of phone numbers detected and masked in text
  - `detected.ssn` — number · Number of social security numbers detected and masked in text
  - `detected.credit_card` — number · Number of credit card numbers detected and masked in text
  - `detected.ip_address` — number · Number of IP addresses detected and masked in text
  - `detected.url` — number · Number of URLs detected and masked in text
  - `detected.date` — number · Number of dates detected and masked in text

## Sample response

```json
{
  "status": "ok",
  "error": null,
  "data": {
    "masked": "Contact John Doe at [EMAIL] or call [PHONE]. His SSN is [SSN].",
    "detected": {
      "email": 1,
      "phone": 1,
      "ssn": 1,
      "credit_card": 0,
      "ip_address": 0,
      "url": 0,
      "date": 0
    }
  }
}
```

## Use cases

- **GDPR Compliance** — Automatically mask PII in logs, documents, and communications to comply with GDPR and privacy regulations
- **Data Anonymization** — Anonymize sensitive customer data in datasets before sharing with third parties or using for testing
- **Log Sanitization** — Remove sensitive information from application logs and error messages before storing or analyzing
- **Content Moderation** — Mask sensitive data in user-generated content, support tickets, or public forums to protect privacy

## SDKs

- **npm** — `npm install @apiverve/datamasking` (https://www.npmjs.com/package/@apiverve/datamasking)
- **NuGet** — `dotnet add package APIVerve.API.DataMasking` (https://www.nuget.org/packages/APIVerve.API.DataMasking)
- **Source** — https://github.com/apiverve/datamasking-api

## More

- Full reference: https://docs.apiverve.com/ref/datamasking
- Get an API key: https://dashboard.apiverve.com
- Full catalog: https://apiverve.com/marketplace
