---
title: "Improve your prompts security with instruction defense"
method: POST
path: "/keep"
---

# Improve your prompts security with instruction defense

`POST /keep`

## Request

- Base URL: `https://prompt.safetorun.com`
- URL: `https://prompt.safetorun.com/keep`
- Auth: API key in header `x-api-key`

This endpoint accepts a text prompt, strips PII, and checks it for prompt injection, returning an injection score.

## Request body

- KeepRequest
  - `randomise_xml_tag` boolean: Whether to randomise the XML tag that is used to escape user input in your prompt.
  - `prompt` string, required: The base prompt you want to build a keep for

## Response `200`

Successful operation.

- KeepResponse
  - `canary` string: The canary string that is used to detect prompt injection.
  - `shielded_prompt` string, required: The shielded prompt.
  - `xml_tag` string, required: The XML tag that is used to escape user input in your prompt.

## Other responses

- `400`: Bad request. The prompt field is missing or invalid.
- `500`: Internal server error.

---

[API](https://skmtc.dev/safetorun/apis/promptdefender-pii-and-prompt-injection-verification-service.md) - [All operations](https://skmtc.dev/safetorun/apis/promptdefender-pii-and-prompt-injection-verification-service/llms.txt) - [OpenAPI document](https://skmtc.dev/safetorun/apis/promptdefender-pii-and-prompt-injection-verification-service/revisions/d7e556f931cd?raw)
