Skip to content
maskera

Use the API in your Gateway installation

The examples use the placeholder address maskera-gateway.ert-natverk.internal. Replace it with the base URL in your installation package. Read about installation and requirements.

For the complete architecture, company identity and operational boundaries: see how Gateway works technically.

The interface is translated, but example text and API payloads remain in Swedish because Maskera is built to mask Swedish text; it does not translate it.

Include your key

Every request needs the Gateway key from your customer delivery in the Authorization field. Keep it in your secret manager and never send it in logs or client-side code.

Authorization: Bearer $MASKERA_GATEWAY_KEY

Mask text

Send text and receive a masked version. When your policy allows restoration, the response also contains a restoration key that maps placeholders to original values. Gateway does not send the original text or restoration key to Maskera.

curl -s https://maskera-gateway.ert-natverk.internal/v1/mask \
  -H "Authorization: Bearer $MASKERA_GATEWAY_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": "Min granne Lars bor på Kungsholmen, personnummer 19900101-0000."}'

Response:

{
  "text": "Min granne [NAMN_1] bor på [PLATS_1], personnummer [PERSONNUMMER_1].",
  "map": {
    "[NAMN_1]": "Lars",
    "[PLATS_1]": "Kungsholmen",
    "[PERSONNUMMER_1]": "19900101-0000"
  },
  "entities": { "NAMN": 1, "PLATS": 1, "PERSONNUMMER": 1 },
  "meta": { "ner": true, "duration_ms": 24, "chars": 62, "policy": "default" }
}
textrequired
The text to mask. At least 1 character; the default limit is 100,000 characters and is controlled by your policy.
ner
Set this to false if you only want to find personal identity numbers, phone numbers, email addresses and card numbers. It is faster but does not find names or places, and requires your policy to allow rule-based masking.
return_map
Set this to false if you do not need the restoration key. Your policy can also disable the key, and true cannot override the policy.

Protect an AI conversation

The request has the same format as OpenAI. Only change the URL in your existing code. Gateway replaces detected personal data before the AI request and restores it in the response. The AI service key is stored in Gateway's configuration, so your application never needs to handle it.

curl -s https://maskera-gateway.ert-natverk.internal/v1/openai/chat/completions \
  -H "Authorization: Bearer $MASKERA_GATEWAY_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [
      {"role": "user", "content": "Sammanfatta: Lars Svensson ringde om fakturan."}
    ]
  }'

In Python, the official OpenAI SDK is unchanged: only base_url changes.

from openai import OpenAI
import os

client = OpenAI(
    api_key=os.environ["MASKERA_GATEWAY_KEY"],
    base_url="https://maskera-gateway.ert-natverk.internal/v1/openai",
)

Error codes

The error message does not contain your text. The response uses this format: {"error": {"message": "Description of the error"}}. The status code indicates the type of error that occurred.

CodeMeaning
400Text is missing or the request has an invalid format
401The key or identity is missing, incorrect or disabled
403Your policy or identity does not allow the action
413The text or complete request is too large
422The AI request contains fields the proxy does not support
502The AI service could not be reached or returned an invalid response
503The license is invalid, the model is not ready or the service is temporarily at capacity

When there are too many concurrent requests, Gateway responds with 503 and a Retry-After field. Wait that number of seconds and try again.

Check service status

GET /healthz responds with 200 when the process is running, and GET /readyz when the license is valid and the model is loaded. Use them in your monitoring system.

{ "status": "ok", "version": "1.2.3" }

Update Gateway

The customer portal shows approved releases. Complete guidance for updating, verifying and rolling back is included in the customer delivery's operations guide.

Specification for development tools

The machine-readable OpenAPI file can generate client code and be used in API tools: /gateway/openapi.json.