API Reference
Virtual Keys
Prompts
- POSTCreate Prompt
- GETList Prompts
- GETRetrieve Prompt
- PUTUpdate Prompt
- DELDelete Prompt
- PUTPublish Prompt
- GETList Prompt Versions
- GETRetrieve Prompt Version
- PUTUpdate Prompt Version
- Prompt Partials
- Prompt Labels
- Prompt Collections
API Keys
Analytics [BETA]
- Summary
- Groups Paginated Data
- Graphs - Time Series Data
User Invites
Workspaces
Workspace Members
Audit Logs
Guardrails
OpenAPI
Create Guardrail
Creates a new guardrail with specified checks and actions
POST
/
guardrails
Copy
Ask AI
HttpResponse<String> response = Unirest.post("https://api.portkey.ai/v1/guardrails")
.header("x-portkey-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"JWT Authentication Guard\",\n \"organisation_id\": \"550e8400-e29b-41d4-a716-446655440001\",\n \"checks\": [\n {\n \"id\": \"default.jwt\",\n \"parameters\": {\n \"jwksUri\": \"https://example.com/.well-known/jwks.json\",\n \"headerKey\": \"Authorization\",\n \"algorithms\": [\n \"RS256\"\n ],\n \"cacheMaxAge\": 86400,\n \"clockTolerance\": 5,\n \"maxTokenAge\": \"1d\"\n }\n }\n ],\n \"actions\": {\n \"onFail\": \"block\",\n \"message\": \"Invalid JWT token\"\n }\n}")
.asString();
Copy
Ask AI
{
"id": "<string>",
"slug": "<string>",
"version_id": "<string>"
}
Authorizations
Body
application/json
Response
200
application/json
Guardrail created successfully
The response is of type object
.
Was this page helpful?
Copy
Ask AI
HttpResponse<String> response = Unirest.post("https://api.portkey.ai/v1/guardrails")
.header("x-portkey-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"JWT Authentication Guard\",\n \"organisation_id\": \"550e8400-e29b-41d4-a716-446655440001\",\n \"checks\": [\n {\n \"id\": \"default.jwt\",\n \"parameters\": {\n \"jwksUri\": \"https://example.com/.well-known/jwks.json\",\n \"headerKey\": \"Authorization\",\n \"algorithms\": [\n \"RS256\"\n ],\n \"cacheMaxAge\": 86400,\n \"clockTolerance\": 5,\n \"maxTokenAge\": \"1d\"\n }\n }\n ],\n \"actions\": {\n \"onFail\": \"block\",\n \"message\": \"Invalid JWT token\"\n }\n}")
.asString();
Copy
Ask AI
{
"id": "<string>",
"slug": "<string>",
"version_id": "<string>"
}
Assistant
Responses are generated using AI and may contain mistakes.