POST /v1/patterns

Create custom entity patterns for your organization.

Why Custom Patterns?

Standard entities cover names, emails, etc. Custom patterns let you detect org-specific data like employee IDs (EMP-123456), project codes, internal account numbers, or any custom identifier.

POSThttps://api.ambientmeta.com/v1/patterns

Request Body

FieldTypeRequiredDescription
namestringYesPattern name (e.g., "EMPLOYEE_ID")
patternstringYesRegex pattern to match
descriptionstringNoHuman-readable description
examplesarrayNoExample matches for validation

Example Request

curl -X POST https://api.ambientmeta.com/v1/patterns \
  -H "Authorization: Bearer am_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "EMPLOYEE_ID",
    "pattern": "EMP-[0-9]{6}",
    "description": "Internal employee identifier",
    "examples": ["EMP-123456", "EMP-789012"]
  }'

Response

{
  "pattern_id": "pat_xyz789",
  "name": "EMPLOYEE_ID",
  "status": "active",
  "test_results": {
    "examples_matched": 2,
    "examples_total": 2
  }
}

Using Custom Patterns

Once created, custom patterns are automatically included in sanitization:

from ambientmeta import AmbientMeta

client = AmbientMeta(api_key="am_live_xxx")
result = client.sanitize("Contact EMP-123456 about the project")

print(result.sanitized)
# "Contact [EMPLOYEE_ID_1] about the project"

List Patterns

GET /v1/patterns returns all patterns for your organization.

Delete Patterns

DELETE /v1/patterns/{pattern_id} removes a pattern.