Skip to content

fix: update identity by identity key instead of externalId and fix wrong body for permission and role #3713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 4, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions apps/docs/api-reference/v1/migration/keys.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ curl -X POST https://api.unkey.com/v2/keys.verifyKey \
"permissions": ["documents.read"], // [!code ++]
"roles": ["editor"], // [!code ++]
"identity": { // [!code ++]
"id": "id_123", // [!code ++]
"externalId": "customer_789", // [!code ++]
"meta": {}, // [!code ++]
"ratelimits": [] // [!code ++]
Expand Down Expand Up @@ -469,14 +470,14 @@ In v2, this control is moved to the root key's permissions:
<Tab title="Method & Format Changes">
```bash title="HTTP Method Change" icon="arrow-right"
# v1: GET with query parameters
curl -X GET "https://api.unkey.dev/v1/keys.getKey?keyId=key_123" \ # [!code --]
-H "Authorization: Bearer <your-root-key>" # [!code --]
curl -X GET "https://api.unkey.dev/v1/keys.getKey?keyId=key_123" \
-H "Authorization: Bearer <your-root-key>"

# v2: POST with request body
curl -X POST https://api.unkey.com/v2/keys.getKey \ # [!code ++]
-H "Authorization: Bearer <your-root-key>" \ # [!code ++]
-H "Content-Type: application/json" \ # [!code ++]
-d '{"keyId": "key_123"}' # [!code ++]
curl -X POST https://api.unkey.com/v2/keys.getKey \
-H "Authorization: Bearer <your-root-key>" \
-H "Content-Type: application/json" \
-d '{"keyId": "key_123"}'
```
</Tab>
<Tab title="Response Changes">
Expand Down Expand Up @@ -530,7 +531,6 @@ curl -X POST https://api.unkey.com/v2/keys.getKey \ # [!code ++]
"name": "Production API Key", // [!code ++]
"prefix": "prod", // [!code ++]
"start": "prod_1234", // [!code ++]
"externalId": "customer_789", // [!code ++]
"meta": { // [!code ++]
"plan": "enterprise" // [!code ++]
}, // [!code ++]
Expand All @@ -552,6 +552,12 @@ curl -X POST https://api.unkey.com/v2/keys.getKey \ # [!code ++]
"autoApply": true // [!code ++]
} // [!code ++]
], // [!code ++]
"identity": { // [!code ++]
"id": "id_123", // [!code ++]
"externalId": "customer_789", // [!code ++]
"meta": {}, // [!code ++]
"ratelimits": [] // [!code ++]
}, // [!code ++]
"enabled": true, // [!code ++]
"permissions": ["documents.read"], // [!code ++]
"roles": ["editor"] // [!code ++]
Expand Down Expand Up @@ -734,7 +740,7 @@ curl -X POST https://api.unkey.com/v2/keys.updateKey \

**Key Changes:**
- Endpoint name change: `updateRemaining` → `updateCredits`
- New operation types: `set`, `increment`, `decrement`
- Request changes: `op` → `operation`
- Response format: Direct response → `{meta, data}` envelope

<Tabs>
Expand All @@ -743,14 +749,15 @@ curl -X POST https://api.unkey.com/v2/keys.updateKey \
// v1 Request
{
"keyId": "key_123",
"value": 1000 // [!code --]
"op": "set", // [!code --]
"value": 1000
}

// v2 Request
{
"keyId": "key_123",
"operation": "set", // [!code ++]
"value": 1000 // [!code focus]
"value": 1000
}
```
</Tab>
Expand Down Expand Up @@ -849,6 +856,12 @@ curl -X POST https://api.unkey.com/v2/keys.updateCredits \
"workspaceId": "ws_xyz789", // [!code ++]
"permissions": ["documents.read"], // [!code ++]
"roles": ["editor"], // [!code ++]
"identity": { // [!code ++]
"id": "id_123", // [!code ++]
"externalId": "customer_789", // [!code ++]
"meta": {}, // [!code ++]
"ratelimits": [] // [!code ++]
}, // [!code ++]
"createdAt": "2024-01-15T10:30:00Z" // [!code ++]
} // [!code ++]
}
Expand Down
23 changes: 19 additions & 4 deletions apps/docs/api-reference/v1/migration/ratelimiting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ This guide covers rate limiting functionality including namespace creation, over
Rate limiting endpoints manage request limits, overrides, and namespace-based rate limiting across your API infrastructure.

### Key Changes in v2:

- **Response format**: `result` → `{meta, data}` wrapper
- **Rate limit structure**: Single `ratelimit` object → `ratelimits` array with named limits
- **Override management**: Enhanced override response format with additional metadata
- **Async handling**: Improved `autoApply` parameter (formerly `async`)
- **Async handling**: Removed `async` parameter
- **Resources**: Removed `resources` array.
- **Metadata**: Removed `meta` object.

### Migration Impact:

- **Existing in v1**: Full rate limiting and override management functionality
- **Enhanced in v2**: Improved response format, better override metadata, and new listing capabilities
- **Maintained in v2**: All core rate limiting functionality with backward-compatible request formats
Expand All @@ -27,19 +31,29 @@ Rate limiting endpoints manage request limits, overrides, and namespace-based ra
### POST /v1/ratelimits.limit → POST /v2/ratelimits.limit

**Key Changes:**

- Response format: Direct response → `{meta, data}` envelope
- Enhanced response with additional metadata
- Better override handling

<Tabs>
<Tab title="Request Format">
<Tab title="Request Structure Changes">
```json title="Rate Limit Request" icon="bolt"
{
"namespace": "email_sending",
"identifier": "user_123",
"limit": 100,
"duration": 3600000,
"cost": 1
"cost": 1,
"async": false, // [!code --]
"meta": {}, // [!code --]
"resources": [ // [!code --]
{ // [!code --]
"type": "project", // [!code --]
"id": "p_123", // [!code --]
"name": "unkey" // [!code --]
} // [!code --]
] // [!code --]
}
```
</Tab>
Expand Down Expand Up @@ -725,7 +739,8 @@ for (const override of overrides.data?.overrides || []) {
### Key-Level Rate Limiting Updates
- [ ] Convert `ratelimit` object to `ratelimits` array in key creation
- [ ] Add `name` field to all rate limit configurations
- [ ] Change `async` parameter to `autoApply`
- [ ] Remove `async` parameter
- [ ] Update Key creation to use autoApply if necessary
- [ ] Plan for multiple rate limits per key (different operation types)
- [ ] Update key verification to handle multiple rate limits

Expand Down
2 changes: 1 addition & 1 deletion apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.1.0",
"private": true,
"scripts": {
"dev": "mintlify dev"
"dev": "npx mintlify@latest dev"
},
"keywords": [],
"author": "Andreas Thomas & James Perkins",
Expand Down
56 changes: 15 additions & 41 deletions go/apps/api/openapi/gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading