Skip to main content
POST
/
policies
/
rate-limits
curl --request POST \
--url https://api.portkey.ai/v1/policies/rate-limits \
--header 'Content-Type: application/json' \
--header 'x-portkey-api-key: <api-key>' \
--data '{
"name": "100 RPM per API Key",
"conditions": [
{
"key": "workspace_id",
"value": "workspace-123"
}
],
"group_by": [
{
"key": "api_key"
}
],
"type": "requests",
"unit": "rpm",
"value": 100
}'
{
  "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "object": "policy_usage_limits"
}

Authorizations

x-portkey-api-key
string
header
required

Body

application/json
conditions
object[]
required

Array of conditions that define which requests the policy applies to

Minimum length: 1
group_by
object[]
required

Array of group by fields that define how usage is aggregated

Minimum length: 1
type
enum<string>
required

Policy type

Available options:
requests,
tokens
unit
enum<string>
required

Rate unit:

  • rpm - Requests/Tokens per minute
  • rph - Requests/Tokens per hour
  • rpd - Requests/Tokens per day
Available options:
rpm,
rph,
rpd
value
number
required

Rate limit value

name
string

Policy name

Maximum length: 255
Example:

"100 Requests per Minute"

workspace_id
string

Workspace ID or slug. Required if not using API key authentication.

organisation_id
string<uuid>

Organization ID. Required if not using API key authentication.

Response

Policy created successfully

id
string<uuid>

Created policy UUID

object
string

Resource type

Example:

"policy_usage_limits"