Skip to content

Error Codes

Nick edited this page Nov 27, 2025 · 1 revision

Error Codes Reference

Complete reference for all error codes returned by Masker API.


HTTP Status Codes

200 OK

Request successful.

400 Bad Request

Invalid request format or validation error.

Common Errors:

  • Missing text or json field
  • Empty text field
  • Invalid mode value (must be "mask" or "placeholder")
  • Invalid entities values
  • Both text and json provided

413 Payload Too Large

Request body exceeds size limit.

Limits:

  • Text field: 32KB
  • Total JSON payload: 64KB

500 Internal Server Error

Unexpected server error.


Error Handling Examples

Python

import requests
import time

def redact_with_retry(text, max_retries=3):
    url = "https://masker.kikuai.dev/v1/redact"
    headers = {"Content-Type": "application/json"}
    data = {"text": text, "mode": "placeholder"}
    
    for attempt in range(max_retries):
        try:
            response = requests.post(url, json=data, headers=headers)
            
            if response.status_code == 200:
                return response.json()
            elif response.status_code == 413:
                raise ValueError("Text is too large. Maximum 32KB.")
            else:
                response.raise_for_status()
                
        except requests.exceptions.RequestException as e:
            if attempt == max_retries - 1:
                raise
            time.sleep(2 ** attempt)
    
    raise Exception("Max retries exceeded")

Status Code Summary

Code Meaning Retry? User Action
200 Success No Use response data
400 Bad Request No Fix request format
413 Payload Too Large No Reduce payload size
500 Server Error Yes Retry or contact support

Last Updated: 2025-11-27

Clone this wiki locally