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
https://api.magier.aiAuthentication
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.
X-Api-Key: YOUR_API_KEYDetection 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.
{
"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.
/api/dlp/transform/redactRequired permission: text:redact.
Body Parameters
contentstringrequiredThe text to analyze. Send Unicode text in its original language. See the multilingual examples.
detectorstringrequiredThe detection model to use.
magier-swiftmagier-forgelabelsarray of stringsrequiredThe categories to detect. For Swift, provide exact predefined identifiers. For Forge, provide descriptive, organization-specific labels.
transformobjectrequiredHow detected values should be replaced.
Child parameter
modestring · requiredUse MASK to preserve the value’s length, or REDACTED to replace it with a fixed word. See transform modes.
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.
Before layan@example.com
After *****************Before layan@example.com
After REDACTEDThese 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_NAMEIBAN_CODECREDIT_CARD_NUMBERFINANCIAL_ACCOUNT_NUMBERSWIFT_CODE
Using Forge? Define labels for your own concepts. You do not need to select them from this catalogue.
AGENames, identity & demographicsDATE_OF_BIRTHNames, identity & demographicsDEMOGRAPHIC_DATANames, identity & demographicsFEMALE_NAMENames, identity & demographicsFIRST_NAMENames, identity & demographicsGENDERNames, identity & demographicsLAST_NAMENames, identity & demographicsMALE_NAMENames, identity & demographicsPERSON_NAMENames, identity & demographicsCOUNTRY_DEMOGRAPHICContact & locationDOMAIN_NAMEContact & locationEMAIL_ADDRESSContact & locationGEOGRAPHIC_DATAContact & locationLOCATIONContact & locationLOCATION_COORDINATESContact & locationPHONE_NUMBERContact & locationSTREET_ADDRESSContact & locationURLContact & locationUS_STATEContact & locationUS_TOLLFREE_PHONE_NUMBERContact & locationAMERICAN_BANKERS_CUSIP_IDFinancial & payment dataAUSTRALIA_TAX_FILE_NUMBERFinancial & payment dataCANADA_BANK_ACCOUNTFinancial & payment dataCREDIT_CARD_DATAFinancial & payment dataCREDIT_CARD_EXPIRATION_DATEFinancial & payment dataCREDIT_CARD_NUMBERFinancial & payment dataCREDIT_CARD_TRACK_NUMBERFinancial & payment dataFINANCIAL_ACCOUNT_NUMBERFinancial & payment dataFINANCIAL_IDFinancial & payment dataFRANCE_TAX_IDENTIFICATION_NUMBERFinancial & payment dataGERMANY_SCHUFA_IDFinancial & payment dataGERMANY_TAXPAYER_IDENTIFICATION_NUMBERFinancial & payment dataIBAN_CODEFinancial & payment dataINDIA_GST_INDIVIDUALFinancial & payment dataJAPAN_BANK_ACCOUNTFinancial & payment dataPARAGUAY_TAX_NUMBERFinancial & payment dataPORTUGAL_NIB_NUMBERFinancial & payment dataSWIFT_CODEFinancial & payment dataUK_TAXPAYER_REFERENCEFinancial & payment dataUS_ADOPTION_TAXPAYER_IDENTIFICATION_NUMBERFinancial & payment dataUS_BANK_ROUTING_MICRFinancial & payment dataUS_INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBERFinancial & payment dataUS_PREPARER_TAXPAYER_IDENTIFICATION_NUMBERFinancial & payment dataVAT_NUMBERFinancial & payment dataARGENTINA_DNI_NUMBERGovernment IDs & travel documentsARMENIA_PASSPORTGovernment IDs & travel documentsAUSTRALIA_DRIVERS_LICENSE_NUMBERGovernment IDs & travel documentsAUSTRALIA_PASSPORTGovernment IDs & travel documentsAUSTRIA_SOCIAL_SECURITY_NUMBERGovernment IDs & travel documentsAZERBAIJAN_PASSPORTGovernment IDs & travel documentsBELARUS_PASSPORTGovernment IDs & travel documentsBELGIUM_NATIONAL_ID_CARD_NUMBERGovernment IDs & travel documentsBRAZIL_CPF_NUMBERGovernment IDs & travel documentsCANADA_DRIVERS_LICENSE_NUMBERGovernment IDs & travel documentsCANADA_PASSPORTGovernment IDs & travel documentsCANADA_SOCIAL_INSURANCE_NUMBERGovernment IDs & travel documentsCHILE_CDI_NUMBERGovernment IDs & travel documentsCHINA_PASSPORTGovernment IDs & travel documentsCHINA_RESIDENT_ID_NUMBERGovernment IDs & travel documentsCOLOMBIA_CDC_NUMBERGovernment IDs & travel documentsCROATIA_PERSONAL_ID_NUMBERGovernment IDs & travel documentsCZECHIA_PASSPORTGovernment IDs & travel documentsCZECHIA_PERSONAL_ID_NUMBERGovernment IDs & travel documentsDENMARK_CPR_NUMBERGovernment IDs & travel documentsDOD_ID_NUMBERGovernment IDs & travel documentsDRIVERS_LICENSE_NUMBERGovernment IDs & travel documentsFINLAND_BUSINESS_IDGovernment IDs & travel documentsFINLAND_NATIONAL_ID_NUMBERGovernment IDs & travel documentsFRANCE_CNIGovernment IDs & travel documentsFRANCE_DRIVERS_LICENSE_NUMBERGovernment IDs & travel documentsFRANCE_NIRGovernment IDs & travel documentsFRANCE_PASSPORTGovernment IDs & travel documentsGERMANY_DRIVERS_LICENSE_NUMBERGovernment IDs & travel documentsGERMANY_IDENTITY_CARD_NUMBERGovernment IDs & travel documentsGERMANY_PASSPORTGovernment IDs & travel documentsGOVERNMENT_IDGovernment IDs & travel documentsHONG_KONG_ID_NUMBERGovernment IDs & travel documentsIMMIGRATION_STATUSGovernment IDs & travel documentsINDIA_AADHAAR_INDIVIDUALGovernment IDs & travel documentsINDIA_PAN_INDIVIDUALGovernment IDs & travel documentsINDIA_PASSPORTGovernment IDs & travel documentsINDONESIA_NIK_NUMBERGovernment IDs & travel documentsINDONESIA_PASSPORTGovernment IDs & travel documentsIRELAND_DRIVING_LICENSE_NUMBERGovernment IDs & travel documentsIRELAND_EIRCODEGovernment IDs & travel documentsIRELAND_PASSPORTGovernment IDs & travel documentsIRELAND_PPSNGovernment IDs & travel documentsISRAEL_IDENTITY_CARD_NUMBERGovernment IDs & travel documentsITALY_FISCAL_CODEGovernment IDs & travel documentsITALY_PASSPORTGovernment IDs & travel documentsJAPAN_CORPORATE_NUMBERGovernment IDs & travel documentsJAPAN_DRIVERS_LICENSE_NUMBERGovernment IDs & travel documentsJAPAN_INDIVIDUAL_NUMBERGovernment IDs & travel documentsJAPAN_PASSPORTGovernment IDs & travel documentsKAZAKHSTAN_PASSPORTGovernment IDs & travel documentsKOREA_DRIVERS_LICENSE_NUMBERGovernment IDs & travel documentsKOREA_PASSPORTGovernment IDs & travel documentsKOREA_RRNGovernment IDs & travel documentsMEXICO_CURP_NUMBERGovernment IDs & travel documentsMEXICO_PASSPORTGovernment IDs & travel documentsNETHERLANDS_BSN_NUMBERGovernment IDs & travel documentsNETHERLANDS_PASSPORTGovernment IDs & travel documentsNEW_ZEALAND_DRIVERS_LICENSE_NUMBERGovernment IDs & travel documentsNEW_ZEALAND_IRD_NUMBERGovernment IDs & travel documentsPARAGUAY_CIC_NUMBERGovernment IDs & travel documentsPASSPORTGovernment IDs & travel documentsPERU_DNI_NUMBERGovernment IDs & travel documentsPOLAND_NATIONAL_ID_NUMBERGovernment IDs & travel documentsPOLAND_PASSPORTGovernment IDs & travel documentsPOLAND_PESEL_NUMBERGovernment IDs & travel documentsPORTUGAL_CDC_NUMBERGovernment IDs & travel documentsPORTUGAL_SOCIAL_SECURITY_NUMBERGovernment IDs & travel documentsRUSSIA_PASSPORTGovernment IDs & travel documentsSINGAPORE_NATIONAL_REGISTRATION_ID_NUMBERGovernment IDs & travel documentsSINGAPORE_PASSPORTGovernment IDs & travel documentsSOUTH_AFRICA_ID_NUMBERGovernment IDs & travel documentsSPAIN_CIF_NUMBERGovernment IDs & travel documentsSPAIN_DNI_NUMBERGovernment IDs & travel documentsSPAIN_DRIVERS_LICENSE_NUMBERGovernment IDs & travel documentsSPAIN_NIE_NUMBERGovernment IDs & travel documentsSPAIN_NIF_NUMBERGovernment IDs & travel documentsSPAIN_PASSPORTGovernment IDs & travel documentsSPAIN_SOCIAL_SECURITY_NUMBERGovernment IDs & travel documentsSWEDEN_NATIONAL_ID_NUMBERGovernment IDs & travel documentsSWEDEN_PASSPORTGovernment IDs & travel documentsSWITZERLAND_SOCIAL_SECURITY_NUMBERGovernment IDs & travel documentsTAIWAN_ID_NUMBERGovernment IDs & travel documentsTAIWAN_PASSPORTGovernment IDs & travel documentsTHAILAND_NATIONAL_ID_NUMBERGovernment IDs & travel documentsTURKEY_ID_NUMBERGovernment IDs & travel documentsUK_DRIVERS_LICENSE_NUMBERGovernment IDs & travel documentsUK_ELECTORAL_ROLL_NUMBERGovernment IDs & travel documentsUK_NATIONAL_INSURANCE_NUMBERGovernment IDs & travel documentsUK_PASSPORTGovernment IDs & travel documentsUKRAINE_PASSPORTGovernment IDs & travel documentsURUGUAY_CDI_NUMBERGovernment IDs & travel documentsUS_DRIVERS_LICENSE_NUMBERGovernment IDs & travel documentsUS_EMPLOYER_IDENTIFICATION_NUMBERGovernment IDs & travel documentsUS_PASSPORTGovernment IDs & travel documentsUS_SOCIAL_SECURITY_NUMBERGovernment IDs & travel documentsUS_VEHICLE_IDENTIFICATION_NUMBERGovernment IDs & travel documentsUZBEKISTAN_PASSPORTGovernment IDs & travel documentsVEHICLE_IDENTIFICATION_NUMBERGovernment IDs & travel documentsVENEZUELA_CDI_NUMBERGovernment IDs & travel documentsAUSTRALIA_MEDICARE_NUMBERHealth & medical dataBLOOD_TYPEHealth & medical dataCANADA_BC_PHNHealth & medical dataCANADA_OHIPHealth & medical dataCANADA_QUEBEC_HINHealth & medical dataFDA_CODEHealth & medical dataICD10_CODEHealth & medical dataICD9_CODEHealth & medical dataMEDICAL_DATAHealth & medical dataMEDICAL_IDHealth & medical dataMEDICAL_RECORD_NUMBERHealth & medical dataMEDICAL_TERMHealth & medical dataNEW_ZEALAND_NHI_NUMBERHealth & medical dataSCOTLAND_COMMUNITY_HEALTH_INDEX_NUMBERHealth & medical dataUK_NATIONAL_HEALTH_SERVICE_NUMBERHealth & medical dataUS_DEA_NUMBERHealth & medical dataUS_HEALTHCARE_NPIHealth & medical dataUS_MEDICARE_BENEFICIARY_ID_NUMBERHealth & medical dataAUTH_TOKENCredentials, secrets & authenticationAWS_CREDENTIALSCredentials, secrets & authenticationAZURE_AUTH_TOKENCredentials, secrets & authenticationBASIC_AUTH_HEADERCredentials, secrets & authenticationENCRYPTION_KEYCredentials, secrets & authenticationGCP_API_KEYCredentials, secrets & authenticationGCP_CREDENTIALSCredentials, secrets & authenticationJSON_WEB_TOKENCredentials, secrets & authenticationOAUTH_CLIENT_SECRETCredentials, secrets & authenticationPASSWORDCredentials, secrets & authenticationSECURITY_DATACredentials, secrets & authenticationSSL_CERTIFICATECredentials, secrets & authenticationSTORAGE_SIGNED_URLCredentials, secrets & authenticationTINK_KEYSETCredentials, secrets & authenticationWEAK_PASSWORD_HASHCredentials, secrets & authenticationXSRF_TOKENCredentials, secrets & authenticationADVERTISING_IDTechnical & device identifiersHTTP_COOKIETechnical & device identifiersHTTP_USER_AGENTTechnical & device identifiersICCID_NUMBERTechnical & device identifiersIMEI_HARDWARE_IDTechnical & device identifiersIMSI_IDTechnical & device identifiersIP_ADDRESSTechnical & device identifiersMAC_ADDRESSTechnical & device identifiersMAC_ADDRESS_LOCALTechnical & device identifiersMAC_ADDRESS_UNIVERSALTechnical & device identifiersTECHNICAL_IDTechnical & device identifiersDOCUMENT_TYPE/CONTEXT/FINANCEDocuments, files & contentDOCUMENT_TYPE/CONTEXT/HEALTHDocuments, files & contentDOCUMENT_TYPE/CONTEXT/LEGALDocuments, files & contentDOCUMENT_TYPE/CONTEXT/OBSCENEDocuments, files & contentDOCUMENT_TYPE/CONTEXT/OFFENSIVEDocuments, files & contentDOCUMENT_TYPE/CONTEXT/POLITICSDocuments, files & contentDOCUMENT_TYPE/CONTEXT/RELIGIONDocuments, files & contentDOCUMENT_TYPE/CONTEXT/SEXUALDocuments, files & contentDOCUMENT_TYPE/FINANCE/INVOICEDocuments, files & contentDOCUMENT_TYPE/FINANCE/REGULATORYDocuments, files & contentDOCUMENT_TYPE/FINANCE/SEC_FILINGDocuments, files & contentDOCUMENT_TYPE/HR/RESUMEDocuments, files & contentDOCUMENT_TYPE/LEGAL/BLANK_FORMDocuments, files & contentDOCUMENT_TYPE/LEGAL/BRIEFDocuments, files & contentDOCUMENT_TYPE/LEGAL/COURT_ORDERDocuments, files & contentDOCUMENT_TYPE/LEGAL/LAWDocuments, files & contentDOCUMENT_TYPE/LEGAL/PLEADINGDocuments, files & contentDOCUMENT_TYPE/MEDICAL/RECORDDocuments, files & contentDOCUMENT_TYPE/R&D/DATABASE_BACKUPDocuments, files & contentDOCUMENT_TYPE/R&D/PATENTDocuments, files & contentDOCUMENT_TYPE/R&D/SOURCE_CODEDocuments, files & contentDOCUMENT_TYPE/R&D/SOURCE_CODE/CDocuments, files & contentDOCUMENT_TYPE/R&D/SOURCE_CODE/CPPDocuments, files & contentDOCUMENT_TYPE/R&D/SOURCE_CODE/CSDocuments, files & contentDOCUMENT_TYPE/R&D/SOURCE_CODE/GODocuments, files & contentDOCUMENT_TYPE/R&D/SOURCE_CODE/HTMLDocuments, files & contentDOCUMENT_TYPE/R&D/SOURCE_CODE/JAVADocuments, files & contentDOCUMENT_TYPE/R&D/SOURCE_CODE/JAVASCRIPTDocuments, files & contentDOCUMENT_TYPE/R&D/SOURCE_CODE/JSONDocuments, files & contentDOCUMENT_TYPE/R&D/SOURCE_CODE/PHPDocuments, files & contentDOCUMENT_TYPE/R&D/SOURCE_CODE/POWERSHELLDocuments, files & contentDOCUMENT_TYPE/R&D/SOURCE_CODE/PYTHONDocuments, files & contentDOCUMENT_TYPE/R&D/SOURCE_CODE/RUSTDocuments, files & contentDOCUMENT_TYPE/R&D/SOURCE_CODE/SHELLDocuments, files & contentDOCUMENT_TYPE/R&D/SOURCE_CODE/SQLDocuments, files & contentDOCUMENT_TYPE/R&D/SOURCE_CODE/TYPESCRIPTDocuments, files & contentDOCUMENT_TYPE/R&D/SYSTEM_LOGDocuments, files & contentOBJECT_TYPE/BARCODEDocuments, files & contentOBJECT_TYPE/LICENSE_PLATEDocuments, files & contentOBJECT_TYPE/PERSONDocuments, files & contentOBJECT_TYPE/PERSON/PASSPORTDocuments, files & contentOBJECT_TYPE/PERSON/PHOTO_ID_CARDDocuments, files & contentOBJECT_TYPE/WHITEBOARDDocuments, files & contentSTORAGE_SIGNED_POLICY_DOCUMENTDocuments, files & contentCRIME_STATUSLegal, employment & sensitive contextEMPLOYMENT_STATUSLegal, employment & sensitive contextETHNIC_GROUPLegal, employment & sensitive contextMARITAL_STATUSLegal, employment & sensitive contextORGANIZATION_NAMELegal, employment & sensitive contextPOLITICAL_TERMLegal, employment & sensitive contextRELIGIOUS_TERMLegal, employment & sensitive contextSEXUAL_ORIENTATIONLegal, employment & sensitive contextTRADE_UNIONLegal, employment & sensitive contextBRAZIL_RG_NUMBEROther identifiersCVV_NUMBEROther identifiersDATEOther identifiersGENERIC_IDOther identifiersKOREA_ARNOther identifiersNORWAY_NI_NUMBEROther identifiersTIMEOther identifiersMultilingual 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.
{
"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"
}
}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_typesstringoptionalThe 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_likelihoodstringoptionalThe minimum confidence required to include a finding. Defaults to POSSIBLE. A higher threshold returns fewer findings.
VERY_UNLIKELYUNLIKELYPOSSIBLELIKELYVERY_LIKELYuse_normalizationbooleanoptionalNormalize whitespace in extracted text before detection. Defaults to true.
PDF application/pdf
PNG image/png
JPEG image/jpeg
WebP image/webpAutomatically Redact a File
Upload a file to detect sensitive text and redact the findings in one request.
/api/dlp/document/v1/redact-autoRequired permission: file:redact:auto.
Form Parameters
filefilerequiredThe PDF or image to redact.
fill_colorstringoptionalThe 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.
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.pdfSet 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.
/api/dlp/document/v1/analyzeRequired permission: file:analyze.
Form Parameters
filefilerequiredThe PDF or image to analyze.
max_pagesintegeroptionalThe 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_idstringIdentifies the analysis. Send this value when redacting selected findings with the same API key and original file.
analysis_expires_atstringThe expiry time in UTC. An analysis is valid for 30 minutes and supports up to 10 redaction attempts.
entitiesarrayThe 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_countintegerThe number of pages analyzed.
entity_countintegerThe number of findings. If this is zero, there are no findings to select for redaction.
input_tokensintegerThe input-token count for the extracted text.
tagged_contentstringThe extracted text with findings marked by tags. This field and the entity values contain the original text.
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.jsonSet 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.
/api/dlp/document/v1/redactRequired permission: file:redact. Your key also needs file:analyze to create the analysis.
Form Parameters
filefilerequiredThe original PDF or image, unchanged since analysis.
analysis_idstringrequiredThe value returned by Analyze a File.
entity_idsstringrequiredA JSON array of the coords.id values to redact. Include at least one ID from the analysis.
fill_colorstringoptionalThe 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.
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.pdfSet 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 requestCheck required fields, selected entity IDs, and page limits. Confirm that the file is valid and the PDF is not password-protected.
403Access deniedCheck the key's permissions. For selected redaction, use the key that created the analysis.
404Analysis not foundRun analysis again and use the new analysis_id and entity IDs.
409File mismatchUpload the same file used for analysis. If the file has changed, analyze it again.
410Analysis expiredRun analysis again and use the new IDs.
413Request too largeReduce the file size or the number of findings selected.
415Unsupported fileUse PDF, PNG, JPEG, or WebP. Match the filename extension and the file part's content type to the actual format.
429Limit reachedCheck 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// 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();