Overview
Both v1 and v2 have standalone permission and role management endpoints. The main differences are in request/response formats, HTTP methods, and enhanced functionality in v2.Key Changes in v2:
- Response format: Direct responses → 
{meta, data}envelope - HTTP methods: Some GET → POST changes for consistency
 - Enhanced pagination: Better pagination support in list endpoints
 - Domain change: 
api.unkey.dev→api.unkey.com 
Migration Impact:
- Both versions: Have standalone permission and role endpoints
 - v2 Enhancement: Improved response format, consistent HTTP methods, simplified permission queries
 - Benefit: Better API consistency, enhanced debugging with request IDs, simplified permission syntax
 
POST /v1/permissions.createPermission → POST /v2/permissions.createPermission
Purpose: Create a standalone permission that can be reused across keys and roles. Key Changes:- Response format: Direct response → 
{meta, data}envelope - Domain change: 
api.unkey.dev→api.unkey.com 
- cURL Migration
 - Response
 
v1 vs v2: Standalone Permission Creation
GET /v1/permissions.getPermission → POST /v2/permissions.getPermission
Purpose: Retrieve permission details by name. Key Changes:- HTTP method: GET → POST
 - Request format: Query parameters → Request body
 - Response format: Direct response → 
{meta, data}envelope - Lookup Permission by either ID or Slug
 
- cURL Migration
 - Response
 
v1 vs v2: Direct Permission Retrieval
GET /v1/permissions.listPermissions → POST /v2/permissions.listPermissions
Purpose: Get paginated list of all permissions. Key Changes:- HTTP method: GET → POST
 - Request format: Query parameters → Request body
 - Response format: Direct array → 
{meta, data}envelope with pagination 
- cURL Migration
 - Response
 
v1 vs v2: Direct Permission Listing
POST /v1/permissions.deletePermission → POST /v2/permissions.deletePermission
Purpose: Permanently delete a permission globally. Key Changes:- Response format: Direct response → 
{meta, data}envelope - Delete permission by ID or slug
 - Domain change: 
api.unkey.dev→api.unkey.com 
- cURL Migration
 - Response
 
v1 vs v2: Global Permission Deletion
Role-Based Access Control (RBAC) Migration
Purpose: Group permissions into roles for easier management - available in both v1 and v2. Key Changes:- Response format: Direct responses → 
{meta, data}envelope - Enhanced role listing with better pagination in v2
 
POST /v1/permissions.createRole → POST /v2/permissions.createRole
- v2 Role Creation
 - Response
 - Assign to Key
 
v1 vs v2: Role Creation
GET /v1/permissions.getRole → POST /v2/permissions.getRole
- Lookup role by either ID or name
 
- v2 Role Retrieval
 - Response
 
v1 vs v2: Role Retrieval
GET /v1/permissions.listRoles → POST /v2/permissions.listRoles
- v2 Role Listing
 - Response
 
v1 vs v2: Role Listing
POST /v1/permissions.deleteRole → POST /v2/permissions.deleteRole
- Delete role by either ID or name
 
- v2 Role Deletion
 - Response
 
v1 vs v2: Role Deletion
Permission Query Migration: v1 Object → v2 String Syntax
Key Change: v2 simplifies permission queries from complex object syntax to intuitive string syntax.- AND Operations
 - OR Operations
 - Complex Queries
 - cURL Examples
 
AND Query Migration
Migration Patterns
Response Format Migration
- Response Format Migration
 
v1 vs v2: Standalone Permission Management
RBAC Implementation Patterns
- RBAC Implementation Migration
 
v1 vs v2: RBAC Implementation Patterns
Key Benefits of v2 Permission Management
Reusable Permission Definitions
Standalone permission creation
Role-Based Access Control
Role with grouped permissions
Auto-Creation Support
Auto-create when referenced
Simplified Query Syntax
String-based permission queries
Migration Checklist
Pattern Migration
- Identify current v1 permission and role usage patterns
 - Update HTTP methods (GET → POST for some endpoints)
 - Update request formats (query parameters → request body)
 - Update response parsing (direct → envelope format)
 
Enhanced Functionality
-  Update to v2 envelope response format with 
meta.requestId - Use enhanced pagination in list endpoints
 -  Update domain from 
api.unkey.devtoapi.unkey.com - Leverage auto-creation for dynamic permission scenarios
 
Query Syntax Migration
- Convert object-based permission queries to string syntax in key verification
 -  Update AND operations: 
{"and": []}→"perm1 AND perm2" -  Update OR operations: 
{"or": []}→"perm1 OR perm2" -  Handle complex nested queries with parentheses: 
"perm1 AND (perm2 OR perm3)" 
Response Format Updates
-  Update response parsing from direct format to 
response.data -  Extract and log 
meta.requestIdfrom responses for debugging - Handle new error structure with meta envelope
 
Testing
- Test HTTP method changes (GET → POST)
 - Verify request body format vs query parameters
 - Test permission queries with new string syntax
 - Confirm envelope response format parsing