Skip to content

Commit 362674e

Browse files
Merge pull request #138 from Portkey-AI/feat/api-key-rotation-policy
feat: add api key rotation policy and update
2 parents 50b8a64 + 0751ab2 commit 362674e

1 file changed

Lines changed: 143 additions & 0 deletions

File tree

openapi.yaml

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17362,6 +17362,31 @@ paths:
1736217362
application/json:
1736317363
schema:
1736417364
$ref: "#/components/schemas/CreateApiKeyObject"
17365+
examples:
17366+
create_basic:
17367+
summary: Create a basic service API key
17368+
value:
17369+
name: "API_KEY_NAME_0909"
17370+
scopes: ["completions.write"]
17371+
create_with_rotation:
17372+
summary: Create an API key with automatic monthly rotation
17373+
value:
17374+
name: "Auto-rotating Key"
17375+
scopes: ["completions.write"]
17376+
rotation_policy:
17377+
rotation_period: "monthly"
17378+
key_transition_period_ms: 3600000
17379+
create_with_usage_limits:
17380+
summary: Create an API key with usage limits and alert emails
17381+
value:
17382+
name: "Budget-limited Key"
17383+
scopes: ["completions.write"]
17384+
usage_limits:
17385+
type: "cost"
17386+
credit_limit: 100
17387+
alert_threshold: 80
17388+
periodic_reset: "monthly"
17389+
alert_emails: ["admin@example.com"]
1736517390
responses:
1736617391
"200":
1736717392
description: OK
@@ -17771,6 +17796,21 @@ paths:
1777117796
summary: Reset accumulated usage for this key
1777217797
value:
1777317798
reset_usage: true
17799+
set_rotation_policy:
17800+
summary: Set automatic monthly rotation on an existing key
17801+
value:
17802+
rotation_policy:
17803+
rotation_period: "monthly"
17804+
key_transition_period_ms: 3600000
17805+
update_usage_limits:
17806+
summary: Update usage limits and alert emails
17807+
value:
17808+
usage_limits:
17809+
type: "cost"
17810+
credit_limit: 100
17811+
alert_threshold: 80
17812+
periodic_reset: "monthly"
17813+
alert_emails: ["admin@example.com"]
1777417814
parameters:
1777517815
- name: id
1777617816
in: path
@@ -31809,6 +31849,21 @@ components:
3180931849
type: string
3181031850
description: Reset the usage periodically.
3181131851
enum: ["monthly", "weekly"]
31852+
nullable: true
31853+
example: "monthly"
31854+
periodic_reset_days:
31855+
type: integer
31856+
description: Reset the usage counter every N days (1-365). Mutually exclusive with periodic_reset.
31857+
minimum: 1
31858+
maximum: 365
31859+
nullable: true
31860+
example: 30
31861+
next_usage_reset_at:
31862+
type: string
31863+
format: date-time
31864+
description: ISO 8601 datetime for the next scheduled usage reset. Auto-computed from periodic_reset or periodic_reset_days if not provided.
31865+
nullable: true
31866+
example: "2026-05-01T00:00:00Z"
3181231867
example:
3181331868
credit_limit: 10
3181431869
periodic_reset: monthly
@@ -34447,6 +34502,11 @@ components:
3444734502
description:
3444834503
type: string
3444934504
example: "API key for development environment"
34505+
organisation_id:
34506+
type: string
34507+
format: uuid
34508+
description: Organisation ID. Optional when calling via an org-level API key (picked from auth context).
34509+
example: "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
3445034510
workspace_id:
3445134511
type: string
3445234512
example: "ws-myworkspace"
@@ -34457,17 +34517,26 @@ components:
3445734517
example: "c3d4e5f6-a7b8-6c7d-0e1f-2a3b4c5d6e7f"
3445834518
rate_limits:
3445934519
type: array
34520+
nullable: true
3446034521
items:
3446134522
type: object
34523+
required:
34524+
- type
34525+
- unit
34526+
- value
3446234527
properties:
3446334528
type:
3446434529
type: string
34530+
enum: ["requests", "tokens"]
3446534531
example: "requests"
3446634532
unit:
3446734533
type: string
34534+
enum: ["rpd", "rph", "rpm", "rps", "rpw"]
34535+
description: "Rate limit unit: requests/tokens per day, hour, minute, second, or week."
3446834536
example: "rpm"
3446934537
value:
3447034538
type: integer
34539+
minimum: 0
3447134540
example: 100
3447234541
usage_limits:
3447334542
$ref: "#/components/schemas/UsageLimits"
@@ -34488,6 +34557,11 @@ components:
3448834557
config_id:
3448934558
type: string
3449034559
example: config-abc
34560+
allow_config_override:
34561+
type: boolean
34562+
default: true
34563+
description: When false, the pinned config_id cannot be overridden at request time.
34564+
example: false
3449134565
alert_emails:
3449234566
type: array
3449334567
items:
@@ -34497,6 +34571,31 @@ components:
3449734571
expires_at:
3449834572
type: string
3449934573
format: date-time
34574+
nullable: true
34575+
description: ISO 8601 datetime at which this key expires. Must not exceed the org/workspace maximum TTL if configured.
34576+
example: "2026-12-31T23:59:59Z"
34577+
rotation_policy:
34578+
type: object
34579+
nullable: true
34580+
description: Automatic key rotation configuration. Requires either rotation_period or next_rotation_at.
34581+
properties:
34582+
rotation_period:
34583+
type: string
34584+
enum: ["weekly", "monthly"]
34585+
nullable: true
34586+
description: How often to automatically rotate the key.
34587+
example: "monthly"
34588+
next_rotation_at:
34589+
type: string
34590+
format: date-time
34591+
nullable: true
34592+
description: Explicit datetime for the next rotation. Mutually exclusive with rotation_period.
34593+
example: "2026-06-01T00:00:00Z"
34594+
key_transition_period_ms:
34595+
type: integer
34596+
minimum: 1800000
34597+
description: Duration in milliseconds during which the previous key remains valid after rotation. Minimum 30 minutes (1800000). Must be less than the full rotation period.
34598+
example: 3600000
3450034599

3450134600
UpdateApiKeyObject:
3450234601
type: object
@@ -34509,17 +34608,26 @@ components:
3450934608
example: "API key for development environment"
3451034609
rate_limits:
3451134610
type: array
34611+
nullable: true
3451234612
items:
3451334613
type: object
34614+
required:
34615+
- type
34616+
- unit
34617+
- value
3451434618
properties:
3451534619
type:
3451634620
type: string
34621+
enum: ["requests", "tokens"]
3451734622
example: "requests"
3451834623
unit:
3451934624
type: string
34625+
enum: ["rpd", "rph", "rpm", "rps", "rpw"]
34626+
description: "Rate limit unit: requests/tokens per day, hour, minute, second, or week."
3452034627
example: "rpm"
3452134628
value:
3452234629
type: integer
34630+
minimum: 0
3452334631
example: 100
3452434632
usage_limits:
3452534633
$ref: "#/components/schemas/UsageLimits"
@@ -34544,12 +34652,45 @@ components:
3454434652
config_id:
3454534653
type: string
3454634654
example: config-abc
34655+
allow_config_override:
34656+
type: boolean
34657+
default: true
34658+
description: When false, the pinned config_id cannot be overridden at request time.
34659+
example: false
3454734660
alert_emails:
3454834661
type: array
3454934662
items:
3455034663
type: string
3455134664
format: email
3455234665
example: "foo@bar.com"
34666+
expires_at:
34667+
type: string
34668+
format: date-time
34669+
nullable: true
34670+
description: ISO 8601 datetime at which this key expires.
34671+
example: "2026-12-31T23:59:59Z"
34672+
rotation_policy:
34673+
type: object
34674+
nullable: true
34675+
description: Update or replace the automatic key rotation configuration. Requires either rotation_period or next_rotation_at.
34676+
properties:
34677+
rotation_period:
34678+
type: string
34679+
enum: ["weekly", "monthly"]
34680+
nullable: true
34681+
description: How often to automatically rotate the key.
34682+
example: "monthly"
34683+
next_rotation_at:
34684+
type: string
34685+
format: date-time
34686+
nullable: true
34687+
description: Explicit datetime for the next rotation. Mutually exclusive with rotation_period.
34688+
example: "2026-06-01T00:00:00Z"
34689+
key_transition_period_ms:
34690+
type: integer
34691+
minimum: 1800000
34692+
description: Duration in milliseconds during which the previous key remains valid after rotation. Minimum 30 minutes (1800000). Must be less than the full rotation period.
34693+
example: 3600000
3455334694

3455434695
RotateApiKeyRequest:
3455534696
type: object
@@ -35838,6 +35979,8 @@ components:
3583835979
description: Inference endpoint
3583935980
metadata:
3584035981
description: metadata related for the batch job
35982+
type: object
35983+
additionalProperties: true
3584135984
nullable: true
3584235985
description: Gateway supported body params for OpenAI, Azure OpenAI and VertexAI.
3584335986
title: OpenAI Params

0 commit comments

Comments
 (0)