> For the complete documentation index, see [llms.txt](https://doc.threatreaper.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.threatreaper.ai/api-and-developer-reference/api-endpoints.md).

# 🌐 API Endpoints

All paths are relative to your base URL (see \[overview] (README.md#base-urls)). Unless noted, send and receive `application/json`.

**Legend:** 🔑 = requires `X-API-Key` or `Authorization: Bearer <JWT>` · 🔒 = requires JWT + a specific permission · — = no credit cost

***

### Authentication API

| Method | Path                       | Purpose                                                               | Auth           |
| ------ | -------------------------- | --------------------------------------------------------------------- | -------------- |
| POST   | `/token`                   | Sign in with username/password, get a JWT                             | none           |
| POST   | `/login`                   | Alternative sign-in (JSON body, supports encrypted payload)           | none           |
| POST   | `/auth/select-org`         | Choose an organisation for multi-org accounts                         | pre-auth token |
| POST   | `/auth/switch-org`         | Switch active organisation                                            | 🔑             |
| POST   | `/api/auth/switch-project` | Switch active project/tenant                                          | 🔑             |
| POST   | `/refresh`                 | Exchange a refresh token for a new access/refresh pair                | refresh token  |
| POST   | `/logout`                  | Revoke the current session                                            | 🔑             |
| GET    | `/public-key`              | Get the RSA public key for optional client-side credential encryption | none           |
| POST   | `/api-keys/create`         | Create a long-lived API key                                           | 🔑 (JWT only)  |
| GET    | `/api-keys/list`           | List your API keys (key values are not returned again)                | 🔑 (JWT only)  |
| DELETE | `/api-keys/{key_id}`       | Revoke an API key                                                     | 🔑 (JWT only)  |

Full details and examples: 🔐 Authentication.

***

### AI-Firewall (Raksha) API

The core real-time guardrail endpoints — call these from your own backend or agent around every LLM call.

| Method | Path                              | Purpose                                                       | Auth |
| ------ | --------------------------------- | ------------------------------------------------------------- | ---- |
| POST   | `/v2/raksha/tr_firewall_analyze`  | Analyze a prompt **before** sending it to your model          | 🔑   |
| POST   | `/v2/raksha/tr_firewall_validate` | Validate a model **response** before showing it to the user   | 🔑   |
| POST   | `/v2/raksha/analyze_audio`        | Transcribe an audio file and analyze the resulting text       | 🔑   |
| POST   | `/v2/pii/mask`                    | Redact PII in a piece of text, independent of a full analysis | 🔑   |

See 💻 Request & Response Examples for full request/response bodies.

***

### Autonomous Decisions API

| Method | Path                      | Purpose                                                                                                              | Auth                                  |
| ------ | ------------------------- | -------------------------------------------------------------------------------------------------------------------- | ------------------------------------- |
| POST   | `/api/autonomous/analyze` | Full autonomous decision: ALLOW / BLOCK / CHALLENGE / ESCALATE, with trust scoring, DLP, and optional SOAR ticketing | 🔒 `TR_FIREWALL_POLICIES:VIEW_POLICY` |

This endpoint does everything `tr_firewall_analyze` does, plus per-guardrail autonomous actions, a user trust score, and an aggregate risk score. Use it when you want LockThreat to also decide the *action*, not just flag the *threat*. Rate limit: 30 requests / 60 seconds per user by default.

See the full request/response schema in 💻 Request & Response Examples.

***

### Connectors API

| Method | Path                                          | Purpose                                                           | Auth                             |
| ------ | --------------------------------------------- | ----------------------------------------------------------------- | -------------------------------- |
| GET    | `/api/connectors/list`                        | List all connectors (optionally with real-time status validation) | 🔒 `CONNECTORS:VIEW_CONNECTOR`   |
| POST   | `/api/connectors`                             | Create a connector generically (any `connector_type`)             | 🔒 `CONNECTORS:CREATE_CONNECTOR` |
| POST   | `/api/connectors/aws_cloud`                   | Create an AWS connector                                           | 🔒                               |
| POST   | `/api/connectors/azure_cloud`                 | Create an Azure connector                                         | 🔒                               |
| POST   | `/api/connectors/gcp_cloud`                   | Create a GCP connector                                            | 🔒                               |
| POST   | `/api/connectors/github`                      | Create a GitHub connector                                         | 🔒                               |
| POST   | `/api/connectors/copilot`                     | Create a GitHub Copilot connector                                 | 🔒                               |
| POST   | `/api/connectors/microsoft_copilot`           | Create a Microsoft 365 Copilot connector                          | 🔒                               |
| POST   | `/api/connectors/openai`                      | Create an OpenAI connector                                        | 🔒                               |
| POST   | `/api/connectors/anthropic`                   | Create an Anthropic (Claude) connector                            | 🔒                               |
| POST   | `/api/connectors/gemini`                      | Create a Google Gemini connector                                  | 🔒                               |
| POST   | `/api/connectors/mistral`                     | Create a Mistral connector                                        | 🔒                               |
| POST   | `/api/connectors/meta`                        | Create a Meta (Llama) connector                                   | 🔒                               |
| POST   | `/api/connectors/cohere`                      | Create a Cohere connector                                         | 🔒                               |
| POST   | `/api/connectors/huggingface`                 | Create a Hugging Face connector                                   | 🔒                               |
| POST   | `/api/connectors/bedrock`                     | Create an AWS Bedrock connector                                   | 🔒                               |
| POST   | `/api/connectors/perplexity`                  | Create a Perplexity connector                                     | 🔒                               |
| POST   | `/api/connectors/xai`                         | Create an xAI (Grok) connector                                    | 🔒                               |
| POST   | `/api/connectors/test`                        | Test a connector configuration without saving it                  | 🔑                               |
| GET    | `/api/connectors/{connector_id}`              | Get full connector details                                        | 🔑                               |
| PUT    | `/api/connectors/{connector_id}`              | Update a connector                                                | 🔒                               |
| DELETE | `/api/connectors/{connector_id}`              | Delete a connector                                                | 🔒                               |
| POST   | `/api/connectors/{connector_id}/test`         | Test an existing connector's connection                           | 🔑                               |
| POST   | `/api/connectors/{connector_id}/sync`         | Trigger a background sync                                         | 🔑                               |
| POST   | `/api/connectors/{connector_id}/health-check` | Run a health check and update status                              | 🔑                               |
| GET    | `/api/connectors/{connector_id}/repositories` | List repositories for a GitHub connector                          | 🔑                               |

Field-by-field request bodies for each connector type: 💻 Request & Response Examples.

***

### Policies API

| Method | Path                          | Purpose                                                         | Auth                                    |
| ------ | ----------------------------- | --------------------------------------------------------------- | --------------------------------------- |
| POST   | `/api/policy/create`          | Create a policy (guardrails + thresholds + autonomous settings) | 🔒 `TR_FIREWALL_POLICIES:CREATE_POLICY` |
| GET    | `/api/policy/list`            | List all policies                                               | 🔒 `TR_FIREWALL_POLICIES:VIEW_POLICY`   |
| POST   | `/api/policy/get`             | Get a single policy by ID                                       | 🔒 `TR_FIREWALL_POLICIES:VIEW_POLICY`   |
| PUT    | `/api/policy/update`          | Update a policy                                                 | 🔒 `TR_FIREWALL_POLICIES:UPDATE_POLICY` |
| DELETE | `/api/policy/delete`          | Delete a policy                                                 | 🔒 `TR_FIREWALL_POLICIES:DELETE_POLICY` |
| GET    | `/api/policy/guardrails/list` | List all available guardrails and their default thresholds      | 🔑                                      |
| GET    | `/enable_disable_policy`      | Enable or disable a policy                                      | 🔒                                      |

***

### Projects API

| Method | Path                  | Purpose                              | Auth                                                        |
| ------ | --------------------- | ------------------------------------ | ----------------------------------------------------------- |
| POST   | `/api/project/create` | Create a project and attach a policy | 🔒 `TR_FIREWALL_PROJECTS:CREATE_PROJECT` (consumes credits) |
| GET    | `/api/project/list`   | List all projects                    | 🔑                                                          |
| POST   | `/api/project/get`    | Get a single project by ID           | 🔒 `TR_FIREWALL_PROJECTS:VIEW_PROJECT`                      |
| PUT    | `/api/project/update` | Update a project                     | 🔒                                                          |
| DELETE | `/api/project/delete` | Delete a project                     | 🔒                                                          |

***

### A note on permissions

Endpoints marked 🔒 require both a valid credential **and** your role to hold the named permission in the active project (see **Settings > Roles** in the console). If you get a `403`, check ⚠️ Error Codes before assuming the request itself is wrong.

### Next

* 💻 Request & Response Examples
* ⚠️ Error Codes


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://doc.threatreaper.ai/api-and-developer-reference/api-endpoints.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
