Skip to content
Developers/API Documentation
Open Portal

API Documentation

Detect and redact sensitive information in text and files.

For text, choose a detection model, specify the labels to identify, and select how detected values should be replaced. Use Magier Swift for predefined labels or Magier Forge for concepts defined by your organization.

For PDFs and images, redact detected findings in one request or analyze the file and choose which findings to redact.

On This Page

Authentication

Authenticate every request with your API key in the X-Api-Key header. Your key must have permission for the operation you call.

Send text requests as JSON with Content-Type: application/json. For file requests, use multipart/form-data and let your HTTP client set the request's Content-Type header, including the multipart boundary.

Keep your key on your server. Store it in an environment variable such as MAGIER_API_KEY, and never expose it in client-side code or commit it to source control.

Manage API keys
Authentication header
X-Api-Key: YOUR_API_KEY

Detection Models

For text requests, set detector to select the model. Both models use the same text endpoint and transform modes. File requests use the file detection options.

Magier Swift magier-swift

Optimized for speed. Detects 249 predefined labels, including names, contact details, financial identifiers, and credentials. Use the exact identifiers in the label catalogue.

Magier Forge magier-forge

Optimized for flexibility. Detects dynamically defined concepts such as transaction references, compliance actions, risk classifications, and internal customer identifiers. Supply descriptive labels for the concepts you need.

Both models can be tailored to your organization’s terminology, data, and policies. Specialized models are available where required.

Choose a detector
{
  "detector": "magier-swift",
  "labels": [
    "PERSON_NAME",
    "EMAIL_ADDRESS"
  ]
}

Redact Text

Identify the requested categories in your content and replace detected values using the selected transform mode.

POST/api/dlp/transform/redact

Required permission: text:redact.

Body Parameters

contentstringrequired

The text to analyze. Send Unicode text in its original language. See the multilingual examples.

detectorstringrequired

The detection model to use.

magier-swiftmagier-forge
labelsarray of stringsrequired

The categories to detect. For Swift, provide exact predefined identifiers. For Forge, provide descriptive, organization-specific labels.

transformobjectrequired

How detected values should be replaced.

Child parameter
modestring · required

Use MASK to preserve the value’s length, or REDACTED to replace it with a fixed word. See transform modes.

Request · cURL
curl https://api.magier.ai/api/dlp/transform/redact \
  -H "X-Api-Key: $MAGIER_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "content": "Customer name: Emma Wilson. Email: emma.wilson@example.com.",
  "detector": "magier-swift",
  "labels": [
    "PERSON_NAME",
    "EMAIL_ADDRESS"
  ],
  "transform": {
    "mode": "MASK"
  }
}'

Set MAGIER_API_KEY in your server environment. For bash or another POSIX-compatible shell.

Transform Modes

Set transform.mode explicitly in your request.

MASK

Replaces each detected value with masking characters while preserving its original length.

REDACTED

Replaces each detected value with the word REDACTED, regardless of the original length.

MASK · illustrative text
Before  layan@example.com
After   *****************
REDACTED · illustrative text
Before  layan@example.com
After   REDACTED

These text examples illustrate replacement behavior, not the API response schema.

Swift Label Catalogue

Magier Swift supports 249 predefined labels across 10 categories. Search by identifier or category, then copy a label into your labels array.

Use identifiers exactly as listed, including capitalization, underscores, and other characters.

Common Banking Labels

  • PERSON_NAME
  • IBAN_CODE
  • CREDIT_CARD_NUMBER
  • FINANCIAL_ACCOUNT_NUMBER
  • SWIFT_CODE
Download the complete catalogue PDF

Using Forge? Define labels for your own concepts. You do not need to select them from this catalogue.

249 of 249 labels
AGENames, identity & demographics
DATE_OF_BIRTHNames, identity & demographics
DEMOGRAPHIC_DATANames, identity & demographics
FEMALE_NAMENames, identity & demographics
FIRST_NAMENames, identity & demographics
GENDERNames, identity & demographics
LAST_NAMENames, identity & demographics
MALE_NAMENames, identity & demographics
PERSON_NAMENames, identity & demographics
COUNTRY_DEMOGRAPHICContact & location
DOMAIN_NAMEContact & location
EMAIL_ADDRESSContact & location
GEOGRAPHIC_DATAContact & location
LOCATIONContact & location
LOCATION_COORDINATESContact & location
PHONE_NUMBERContact & location
STREET_ADDRESSContact & location
URLContact & location
US_STATEContact & location
US_TOLLFREE_PHONE_NUMBERContact & location
AMERICAN_BANKERS_CUSIP_IDFinancial & payment data
AUSTRALIA_TAX_FILE_NUMBERFinancial & payment data
CANADA_BANK_ACCOUNTFinancial & payment data
CREDIT_CARD_DATAFinancial & payment data
CREDIT_CARD_EXPIRATION_DATEFinancial & payment data
CREDIT_CARD_NUMBERFinancial & payment data
CREDIT_CARD_TRACK_NUMBERFinancial & payment data
FINANCIAL_ACCOUNT_NUMBERFinancial & payment data
FINANCIAL_IDFinancial & payment data
FRANCE_TAX_IDENTIFICATION_NUMBERFinancial & payment data
GERMANY_SCHUFA_IDFinancial & payment data
GERMANY_TAXPAYER_IDENTIFICATION_NUMBERFinancial & payment data
IBAN_CODEFinancial & payment data
INDIA_GST_INDIVIDUALFinancial & payment data
JAPAN_BANK_ACCOUNTFinancial & payment data
PARAGUAY_TAX_NUMBERFinancial & payment data
PORTUGAL_NIB_NUMBERFinancial & payment data
SWIFT_CODEFinancial & payment data
UK_TAXPAYER_REFERENCEFinancial & payment data
US_ADOPTION_TAXPAYER_IDENTIFICATION_NUMBERFinancial & payment data
US_BANK_ROUTING_MICRFinancial & payment data
US_INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBERFinancial & payment data
US_PREPARER_TAXPAYER_IDENTIFICATION_NUMBERFinancial & payment data
VAT_NUMBERFinancial & payment data
ARGENTINA_DNI_NUMBERGovernment IDs & travel documents
ARMENIA_PASSPORTGovernment IDs & travel documents
AUSTRALIA_DRIVERS_LICENSE_NUMBERGovernment IDs & travel documents
AUSTRALIA_PASSPORTGovernment IDs & travel documents
AUSTRIA_SOCIAL_SECURITY_NUMBERGovernment IDs & travel documents
AZERBAIJAN_PASSPORTGovernment IDs & travel documents
BELARUS_PASSPORTGovernment IDs & travel documents
BELGIUM_NATIONAL_ID_CARD_NUMBERGovernment IDs & travel documents
BRAZIL_CPF_NUMBERGovernment IDs & travel documents
CANADA_DRIVERS_LICENSE_NUMBERGovernment IDs & travel documents
CANADA_PASSPORTGovernment IDs & travel documents
CANADA_SOCIAL_INSURANCE_NUMBERGovernment IDs & travel documents
CHILE_CDI_NUMBERGovernment IDs & travel documents
CHINA_PASSPORTGovernment IDs & travel documents
CHINA_RESIDENT_ID_NUMBERGovernment IDs & travel documents
COLOMBIA_CDC_NUMBERGovernment IDs & travel documents
CROATIA_PERSONAL_ID_NUMBERGovernment IDs & travel documents
CZECHIA_PASSPORTGovernment IDs & travel documents
CZECHIA_PERSONAL_ID_NUMBERGovernment IDs & travel documents
DENMARK_CPR_NUMBERGovernment IDs & travel documents
DOD_ID_NUMBERGovernment IDs & travel documents
DRIVERS_LICENSE_NUMBERGovernment IDs & travel documents
FINLAND_BUSINESS_IDGovernment IDs & travel documents
FINLAND_NATIONAL_ID_NUMBERGovernment IDs & travel documents
FRANCE_CNIGovernment IDs & travel documents
FRANCE_DRIVERS_LICENSE_NUMBERGovernment IDs & travel documents
FRANCE_NIRGovernment IDs & travel documents
FRANCE_PASSPORTGovernment IDs & travel documents
GERMANY_DRIVERS_LICENSE_NUMBERGovernment IDs & travel documents
GERMANY_IDENTITY_CARD_NUMBERGovernment IDs & travel documents
GERMANY_PASSPORTGovernment IDs & travel documents
GOVERNMENT_IDGovernment IDs & travel documents
HONG_KONG_ID_NUMBERGovernment IDs & travel documents
IMMIGRATION_STATUSGovernment IDs & travel documents
INDIA_AADHAAR_INDIVIDUALGovernment IDs & travel documents
INDIA_PAN_INDIVIDUALGovernment IDs & travel documents
INDIA_PASSPORTGovernment IDs & travel documents
INDONESIA_NIK_NUMBERGovernment IDs & travel documents
INDONESIA_PASSPORTGovernment IDs & travel documents
IRELAND_DRIVING_LICENSE_NUMBERGovernment IDs & travel documents
IRELAND_EIRCODEGovernment IDs & travel documents
IRELAND_PASSPORTGovernment IDs & travel documents
IRELAND_PPSNGovernment IDs & travel documents
ISRAEL_IDENTITY_CARD_NUMBERGovernment IDs & travel documents
ITALY_FISCAL_CODEGovernment IDs & travel documents
ITALY_PASSPORTGovernment IDs & travel documents
JAPAN_CORPORATE_NUMBERGovernment IDs & travel documents
JAPAN_DRIVERS_LICENSE_NUMBERGovernment IDs & travel documents
JAPAN_INDIVIDUAL_NUMBERGovernment IDs & travel documents
JAPAN_PASSPORTGovernment IDs & travel documents
KAZAKHSTAN_PASSPORTGovernment IDs & travel documents
KOREA_DRIVERS_LICENSE_NUMBERGovernment IDs & travel documents
KOREA_PASSPORTGovernment IDs & travel documents
KOREA_RRNGovernment IDs & travel documents
MEXICO_CURP_NUMBERGovernment IDs & travel documents
MEXICO_PASSPORTGovernment IDs & travel documents
NETHERLANDS_BSN_NUMBERGovernment IDs & travel documents
NETHERLANDS_PASSPORTGovernment IDs & travel documents
NEW_ZEALAND_DRIVERS_LICENSE_NUMBERGovernment IDs & travel documents
NEW_ZEALAND_IRD_NUMBERGovernment IDs & travel documents
PARAGUAY_CIC_NUMBERGovernment IDs & travel documents
PASSPORTGovernment IDs & travel documents
PERU_DNI_NUMBERGovernment IDs & travel documents
POLAND_NATIONAL_ID_NUMBERGovernment IDs & travel documents
POLAND_PASSPORTGovernment IDs & travel documents
POLAND_PESEL_NUMBERGovernment IDs & travel documents
PORTUGAL_CDC_NUMBERGovernment IDs & travel documents
PORTUGAL_SOCIAL_SECURITY_NUMBERGovernment IDs & travel documents
RUSSIA_PASSPORTGovernment IDs & travel documents
SINGAPORE_NATIONAL_REGISTRATION_ID_NUMBERGovernment IDs & travel documents
SINGAPORE_PASSPORTGovernment IDs & travel documents
SOUTH_AFRICA_ID_NUMBERGovernment IDs & travel documents
SPAIN_CIF_NUMBERGovernment IDs & travel documents
SPAIN_DNI_NUMBERGovernment IDs & travel documents
SPAIN_DRIVERS_LICENSE_NUMBERGovernment IDs & travel documents
SPAIN_NIE_NUMBERGovernment IDs & travel documents
SPAIN_NIF_NUMBERGovernment IDs & travel documents
SPAIN_PASSPORTGovernment IDs & travel documents
SPAIN_SOCIAL_SECURITY_NUMBERGovernment IDs & travel documents
SWEDEN_NATIONAL_ID_NUMBERGovernment IDs & travel documents
SWEDEN_PASSPORTGovernment IDs & travel documents
SWITZERLAND_SOCIAL_SECURITY_NUMBERGovernment IDs & travel documents
TAIWAN_ID_NUMBERGovernment IDs & travel documents
TAIWAN_PASSPORTGovernment IDs & travel documents
THAILAND_NATIONAL_ID_NUMBERGovernment IDs & travel documents
TURKEY_ID_NUMBERGovernment IDs & travel documents
UK_DRIVERS_LICENSE_NUMBERGovernment IDs & travel documents
UK_ELECTORAL_ROLL_NUMBERGovernment IDs & travel documents
UK_NATIONAL_INSURANCE_NUMBERGovernment IDs & travel documents
UK_PASSPORTGovernment IDs & travel documents
UKRAINE_PASSPORTGovernment IDs & travel documents
URUGUAY_CDI_NUMBERGovernment IDs & travel documents
US_DRIVERS_LICENSE_NUMBERGovernment IDs & travel documents
US_EMPLOYER_IDENTIFICATION_NUMBERGovernment IDs & travel documents
US_PASSPORTGovernment IDs & travel documents
US_SOCIAL_SECURITY_NUMBERGovernment IDs & travel documents
US_VEHICLE_IDENTIFICATION_NUMBERGovernment IDs & travel documents
UZBEKISTAN_PASSPORTGovernment IDs & travel documents
VEHICLE_IDENTIFICATION_NUMBERGovernment IDs & travel documents
VENEZUELA_CDI_NUMBERGovernment IDs & travel documents
AUSTRALIA_MEDICARE_NUMBERHealth & medical data
BLOOD_TYPEHealth & medical data
CANADA_BC_PHNHealth & medical data
CANADA_OHIPHealth & medical data
CANADA_QUEBEC_HINHealth & medical data
FDA_CODEHealth & medical data
ICD10_CODEHealth & medical data
ICD9_CODEHealth & medical data
MEDICAL_DATAHealth & medical data
MEDICAL_IDHealth & medical data
MEDICAL_RECORD_NUMBERHealth & medical data
MEDICAL_TERMHealth & medical data
NEW_ZEALAND_NHI_NUMBERHealth & medical data
SCOTLAND_COMMUNITY_HEALTH_INDEX_NUMBERHealth & medical data
UK_NATIONAL_HEALTH_SERVICE_NUMBERHealth & medical data
US_DEA_NUMBERHealth & medical data
US_HEALTHCARE_NPIHealth & medical data
US_MEDICARE_BENEFICIARY_ID_NUMBERHealth & medical data
AUTH_TOKENCredentials, secrets & authentication
AWS_CREDENTIALSCredentials, secrets & authentication
AZURE_AUTH_TOKENCredentials, secrets & authentication
BASIC_AUTH_HEADERCredentials, secrets & authentication
ENCRYPTION_KEYCredentials, secrets & authentication
GCP_API_KEYCredentials, secrets & authentication
GCP_CREDENTIALSCredentials, secrets & authentication
JSON_WEB_TOKENCredentials, secrets & authentication
OAUTH_CLIENT_SECRETCredentials, secrets & authentication
PASSWORDCredentials, secrets & authentication
SECURITY_DATACredentials, secrets & authentication
SSL_CERTIFICATECredentials, secrets & authentication
STORAGE_SIGNED_URLCredentials, secrets & authentication
TINK_KEYSETCredentials, secrets & authentication
WEAK_PASSWORD_HASHCredentials, secrets & authentication
XSRF_TOKENCredentials, secrets & authentication
ADVERTISING_IDTechnical & device identifiers
HTTP_COOKIETechnical & device identifiers
HTTP_USER_AGENTTechnical & device identifiers
ICCID_NUMBERTechnical & device identifiers
IMEI_HARDWARE_IDTechnical & device identifiers
IMSI_IDTechnical & device identifiers
IP_ADDRESSTechnical & device identifiers
MAC_ADDRESSTechnical & device identifiers
MAC_ADDRESS_LOCALTechnical & device identifiers
MAC_ADDRESS_UNIVERSALTechnical & device identifiers
TECHNICAL_IDTechnical & device identifiers
DOCUMENT_TYPE/CONTEXT/FINANCEDocuments, files & content
DOCUMENT_TYPE/CONTEXT/HEALTHDocuments, files & content
DOCUMENT_TYPE/CONTEXT/LEGALDocuments, files & content
DOCUMENT_TYPE/CONTEXT/OBSCENEDocuments, files & content
DOCUMENT_TYPE/CONTEXT/OFFENSIVEDocuments, files & content
DOCUMENT_TYPE/CONTEXT/POLITICSDocuments, files & content
DOCUMENT_TYPE/CONTEXT/RELIGIONDocuments, files & content
DOCUMENT_TYPE/CONTEXT/SEXUALDocuments, files & content
DOCUMENT_TYPE/FINANCE/INVOICEDocuments, files & content
DOCUMENT_TYPE/FINANCE/REGULATORYDocuments, files & content
DOCUMENT_TYPE/FINANCE/SEC_FILINGDocuments, files & content
DOCUMENT_TYPE/HR/RESUMEDocuments, files & content
DOCUMENT_TYPE/LEGAL/BLANK_FORMDocuments, files & content
DOCUMENT_TYPE/LEGAL/BRIEFDocuments, files & content
DOCUMENT_TYPE/LEGAL/COURT_ORDERDocuments, files & content
DOCUMENT_TYPE/LEGAL/LAWDocuments, files & content
DOCUMENT_TYPE/LEGAL/PLEADINGDocuments, files & content
DOCUMENT_TYPE/MEDICAL/RECORDDocuments, files & content
DOCUMENT_TYPE/R&D/DATABASE_BACKUPDocuments, files & content
DOCUMENT_TYPE/R&D/PATENTDocuments, files & content
DOCUMENT_TYPE/R&D/SOURCE_CODEDocuments, files & content
DOCUMENT_TYPE/R&D/SOURCE_CODE/CDocuments, files & content
DOCUMENT_TYPE/R&D/SOURCE_CODE/CPPDocuments, files & content
DOCUMENT_TYPE/R&D/SOURCE_CODE/CSDocuments, files & content
DOCUMENT_TYPE/R&D/SOURCE_CODE/GODocuments, files & content
DOCUMENT_TYPE/R&D/SOURCE_CODE/HTMLDocuments, files & content
DOCUMENT_TYPE/R&D/SOURCE_CODE/JAVADocuments, files & content
DOCUMENT_TYPE/R&D/SOURCE_CODE/JAVASCRIPTDocuments, files & content
DOCUMENT_TYPE/R&D/SOURCE_CODE/JSONDocuments, files & content
DOCUMENT_TYPE/R&D/SOURCE_CODE/PHPDocuments, files & content
DOCUMENT_TYPE/R&D/SOURCE_CODE/POWERSHELLDocuments, files & content
DOCUMENT_TYPE/R&D/SOURCE_CODE/PYTHONDocuments, files & content
DOCUMENT_TYPE/R&D/SOURCE_CODE/RUSTDocuments, files & content
DOCUMENT_TYPE/R&D/SOURCE_CODE/SHELLDocuments, files & content
DOCUMENT_TYPE/R&D/SOURCE_CODE/SQLDocuments, files & content
DOCUMENT_TYPE/R&D/SOURCE_CODE/TYPESCRIPTDocuments, files & content
DOCUMENT_TYPE/R&D/SYSTEM_LOGDocuments, files & content
OBJECT_TYPE/BARCODEDocuments, files & content
OBJECT_TYPE/LICENSE_PLATEDocuments, files & content
OBJECT_TYPE/PERSONDocuments, files & content
OBJECT_TYPE/PERSON/PASSPORTDocuments, files & content
OBJECT_TYPE/PERSON/PHOTO_ID_CARDDocuments, files & content
OBJECT_TYPE/WHITEBOARDDocuments, files & content
STORAGE_SIGNED_POLICY_DOCUMENTDocuments, files & content
CRIME_STATUSLegal, employment & sensitive context
EMPLOYMENT_STATUSLegal, employment & sensitive context
ETHNIC_GROUPLegal, employment & sensitive context
MARITAL_STATUSLegal, employment & sensitive context
ORGANIZATION_NAMELegal, employment & sensitive context
POLITICAL_TERMLegal, employment & sensitive context
RELIGIOUS_TERMLegal, employment & sensitive context
SEXUAL_ORIENTATIONLegal, employment & sensitive context
TRADE_UNIONLegal, employment & sensitive context
BRAZIL_RG_NUMBEROther identifiers
CVV_NUMBEROther identifiers
DATEOther identifiers
GENERIC_IDOther identifiers
KOREA_ARNOther identifiers
NORWAY_NI_NUMBEROther identifiers
TIMEOther identifiers

Multilingual Examples

Explore tested requests in English, German, French, and Spanish. Each example uses synthetic banking data. Choose a language, model, and transform to see the request and its captured output.

Business Account Onboarding

Swift identifies a customer’s full name, email address, and IBAN using PERSON_NAME, EMAIL_ADDRESS, and IBAN_CODE. The label identifiers stay the same across content languages.

Transaction and Compliance Review

Forge identifies transaction references, compliance actions, and risk classifications. These examples use the same descriptive English labels with text in each of the four languages.

All eight requests were tested with both MASK and REDACTED. Detection results depend on the content and model configuration; test your own data before integrating.

English · request body
{
  "content": "Business account application. Customer name: Emma Wilson. Email: emma.wilson@example.com. IBAN: DE89 3704 0044 0532 0130 00.",
  "detector": "magier-swift",
  "labels": [
    "PERSON_NAME",
    "EMAIL_ADDRESS",
    "IBAN_CODE"
  ],
  "transform": {
    "mode": "MASK"
  }
}
HTTP 200 · 3 of 3 requested labels detected
Actual response · redacted_content
Business account application. Customer name: ***********. Email: ***********************. IBAN: ***************************.

Captured from the live API on September 18, 2026. The output above is the response’s redacted_content field, not the full JSON response.

File Redaction

Find sensitive text in PDFs and images, then download a redacted copy. Choose automatic redaction to apply every detected finding, or analyze the file first to review and select findings.

Supported Files

Upload PDF, PNG, JPEG, or WebP files. The file extension and its content type must match the file. Convert Word documents to PDF before uploading. For plain text, use Redact Text.

Send the file in a multipart field named file. Set the content type on the file part, as shown in the examples. For an image, replace both document.pdf and application/pdf with the image's filename and content type.

Default evaluation limits are 25 MiB and 15 pages per file. Password-protected PDFs are not supported.

Detection Options

These optional fields apply to Analyze a File and Automatically Redact a File. Send them as multipart form fields alongside the file.

info_typesstringoptional

The categories to detect, as a JSON array or comma-separated list. For example, ["EMAIL_ADDRESS","PHONE_NUMBER"]. Omit this field to use the default detection categories. File requests use info_types; the text endpoint's detector, labels, and transform fields do not apply.

min_likelihoodstringoptional

The minimum confidence required to include a finding. Defaults to POSSIBLE. A higher threshold returns fewer findings.

VERY_UNLIKELYUNLIKELYPOSSIBLELIKELYVERY_LIKELY
use_normalizationbooleanoptional

Normalize whitespace in extracted text before detection. Defaults to true.

File content types
PDF     application/pdf
PNG     image/png
JPEG    image/jpeg
WebP    image/webp

Automatically Redact a File

Upload a file to detect sensitive text and redact the findings in one request.

POST/api/dlp/document/v1/redact-auto

Required permission: file:redact:auto.

Form Parameters

filefilerequired

The PDF or image to redact.

fill_colorstringoptional

The redaction color. Defaults to black, #000000. Accepts a hex color or an RGB value such as 0,0,0.

To choose categories or a confidence threshold, include the detection options.

Response

Returns the file with detected regions redacted, in the original file format. Save the response body as a file. The Content-Disposition header provides a download filename.

If no findings are detected, the original file contents are returned. Review the output before sharing it.

Request · cURL
curl --fail-with-body "https://api.magier.ai/api/dlp/document/v1/redact-auto" \
  -H "X-Api-Key: $MAGIER_API_KEY" \
  -F "file=@document.pdf;type=application/pdf" \
  --output redacted-document.pdf

Set MAGIER_API_KEY in your server environment and replace document.pdf with your file. Requires cURL 7.76 or later and a POSIX-compatible shell.

Analyze a File

Upload a file to find sensitive text and its position on each page. Use the results to choose which findings to redact.

POST/api/dlp/document/v1/analyze

Required permission: file:analyze.

Form Parameters

filefilerequired

The PDF or image to analyze.

max_pagesintegeroptional

The maximum number of pages to analyze. Defaults to 15. This field does not increase your upload's page limit.

To choose categories or a confidence threshold, include the detection options.

Response

Returns JSON. The example saves it to analysis.json for use in the next request.

analysis_idstring

Identifies the analysis. Send this value when redacting selected findings with the same API key and original file.

analysis_expires_atstring

The expiry time in UTC. An analysis is valid for 30 minutes and supports up to 10 redaction attempts.

entitiesarray

The findings. Each includes infoType, value, likelihood, page, and coords. Use coords.id to select a finding. Page numbers start at 1. The coords.bbox.normalized_rect field gives its position on the page, with coordinates from 0 to 1.

page_countinteger

The number of pages analyzed.

entity_countinteger

The number of findings. If this is zero, there are no findings to select for redaction.

input_tokensinteger

The input-token count for the extracted text.

tagged_contentstring

The extracted text with findings marked by tags. This field and the entity values contain the original text.

Request · cURL
curl --fail-with-body "https://api.magier.ai/api/dlp/document/v1/analyze" \
  -H "X-Api-Key: $MAGIER_API_KEY" \
  -F "file=@document.pdf;type=application/pdf" \
  --output analysis.json

Set MAGIER_API_KEY in your server environment and replace document.pdf with your file. Requires cURL 7.76 or later and a POSIX-compatible shell.

Redact Selected Findings

Apply selected findings from a previous analysis. Upload the same original file and use the API key that created the analysis.

POST/api/dlp/document/v1/redact

Required permission: file:redact. Your key also needs file:analyze to create the analysis.

Form Parameters

filefilerequired

The original PDF or image, unchanged since analysis.

analysis_idstringrequired

The value returned by Analyze a File.

entity_idsstringrequired

A JSON array of the coords.id values to redact. Include at least one ID from the analysis.

fill_colorstringoptional

The redaction color. Defaults to black, #000000. Accepts a hex color or an RGB value such as 0,0,0.

Response

Returns the file with the selected regions redacted, in the original file format. Save the response body as a file. The example below reads analysis.json, selects email-address findings, and saves redacted-document.pdf.

To redact other findings, choose their coords.id values from the analysis. If the analysis expires, run Analyze a File again and use the new IDs.

Request · cURL
analysis_id=$(jq -r '.analysis_id' analysis.json)
entity_ids=$(jq -c '[.entities[] | select(.infoType == "EMAIL_ADDRESS") | .coords.id]' analysis.json)
if [ "$entity_ids" = "[]" ]; then
  printf "%s\n" "No email addresses were found. Choose other findings or keep the original file." >&2
  exit 1
fi

curl --fail-with-body "https://api.magier.ai/api/dlp/document/v1/redact" \
  -H "X-Api-Key: $MAGIER_API_KEY" \
  -F "file=@document.pdf;type=application/pdf" \
  --form-string "analysis_id=$analysis_id" \
  --form-string "entity_ids=$entity_ids" \
  --output redacted-document.pdf

Set MAGIER_API_KEY in your server environment and replace document.pdf with your file. Requires cURL 7.76 or later and a POSIX-compatible shell. Install jq to read the saved analysis.

Handle Responses

Check the HTTP status before consuming the response. Treat a non-success status as a failed request and inspect the response body for details.

Text redaction and file analysis return JSON. File redaction returns a PDF or image; save the response bytes using the file examples above.

For authentication failures, check that you supplied the correct key in X-Api-Key. For request errors, check the detector, label identifiers, and transform mode.

File Request Errors

400Invalid request

Check required fields, selected entity IDs, and page limits. Confirm that the file is valid and the PDF is not password-protected.

403Access denied

Check the key's permissions. For selected redaction, use the key that created the analysis.

404Analysis not found

Run analysis again and use the new analysis_id and entity IDs.

409File mismatch

Upload the same file used for analysis. If the file has changed, analyze it again.

410Analysis expired

Run analysis again and use the new IDs.

413Request too large

Reduce the file size or the number of findings selected.

415Unsupported file

Use PDF, PNG, JPEG, or WebP. Match the filename extension and the file part's content type to the actual format.

429Limit reached

Check the error details for usage, request, or redaction-attempt limits. If the analysis has reached its attempt limit, create a new analysis.

Use to inspect a text response. Avoid logging API keys, original sensitive content, or unredacted responses.

Get integration help
Check a JSON response · Node.js
// After sending a text or analysis request
if (!response.ok) {
  const details = await response.text();
  throw new Error(
    `Magier Shield: ${response.status} ${details}`
  );
}

const result = await response.json();