> ## Documentation Index
> Fetch the complete documentation index at: https://docs.centure.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Scan Text for Prompt Injection

<Info>
  Learn more about the risk categories returned by this endpoint in [Risk Classifications](/security/risk-classifications).
</Info>

## Basic Usage

<CodeGroup>
  ```typescript Node.js theme={null}
  import { CentureClient } from "@centure/node-sdk";

  const client = new CentureClient();

  const result = await client.scanText("External data to scan...");

  if (!result.is_safe) {
    console.log("Detected categories:", result.categories);
  }
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.centure.ai/v1/prompt-injection/text \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "content": "External data to scan..."
    }'
  ```
</CodeGroup>

## Filtering Categories

You can filter which risk categories to detect using the `only` or `exclude` parameters. These parameters are mutually exclusive.

<CodeGroup>
  ```typescript Only specific categories theme={null}
  const result = await client.scanText("External data to scan...", {
    only: ["data_exfiltration", "unauthorized_actions"]
  });
  ```

  ```typescript Exclude categories theme={null}
  const result = await client.scanText("External data to scan...", {
    exclude: ["behavioral_override_low"]
  });
  ```
</CodeGroup>

## Confidence Filtering

Use `minimum_confidence` to filter results by confidence level:

```typescript theme={null}
const result = await client.scanText("External data to scan...", {
  minimum_confidence: "high"
});
```

<Tip>
  Set `minimum_confidence` to `"high"` to reduce false positives by only returning high-confidence detections.
</Tip>

## Response

When content is flagged as unsafe, the response includes a `reason` field explaining why:

```json theme={null}
{
  "is_safe": false,
  "categories": [
    { "code": "data_exfiltration", "confidence": "high" }
  ],
  "reason": "The input attempts to extract system prompt information by asking the model to reveal its instructions.",
  "request_id": "req_abc123",
  "api_key_id": "key_xyz789",
  "request_units": 1,
  "billed_request_units": 1,
  "service_tier": "standard"
}
```


## OpenAPI

````yaml POST /v1/prompt-injection/text
openapi: 3.0.0
info:
  title: Centure API
  version: 1.0.0
  description: API for prompt injection detection
servers: []
security: []
paths:
  /v1/prompt-injection/text:
    post:
      tags:
        - Prompt Injection
      summary: Scan text for prompt injection
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                content:
                  type: string
                  description: Text to scan
                only:
                  type: array
                  items:
                    type: string
                  description: >-
                    Only detect these categories (mutually exclusive with
                    'exclude')
                exclude:
                  type: array
                  items:
                    type: string
                  description: >-
                    Exclude these categories from detection (mutually exclusive
                    with 'only')
                minimum_confidence:
                  type: string
                  enum:
                    - medium
                    - high
                  description: >-
                    Minimum confidence level to include in results. Default:
                    'medium' (include all)
              required:
                - content
      responses:
        '200':
          description: Scan result
          content:
            application/json:
              schema:
                type: object
                properties:
                  is_safe:
                    type: boolean
                  reason:
                    type: string
                  categories:
                    type: array
                    items:
                      type: object
                      properties:
                        code:
                          type: string
                          enum:
                            - output_manipulation
                            - context_injection
                            - data_exfiltration
                            - unauthorized_actions
                        confidence:
                          type: string
                          enum:
                            - medium
                            - high
                      required:
                        - code
                        - confidence
                  request_id:
                    type: string
                  api_key_id:
                    type: string
                  request_units:
                    type: number
                  billed_request_units:
                    type: number
                  service_tier:
                    type: string
                    enum:
                      - low
                      - standard
                      - dedicated
                required:
                  - is_safe
                  - categories
                  - request_id
                  - api_key_id
                  - request_units
                  - billed_request_units
                  - service_tier
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````