POST
/
guardrails
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();
{
  "id": "<string>",
  "slug": "<string>",
  "version_id": "<string>"
}

Authorizations

x-portkey-api-key
string
header
required

Body

application/json

Response

200
application/json

Guardrail created successfully

The response is of type object.