Pratham Khodwe
10/16/2025, 9:56 AMAsk Inkeep
10/16/2025, 9:56 AMAsk Inkeep
10/16/2025, 9:56 AMAsk Inkeep
10/16/2025, 9:57 AMOr Weis
10/16/2025, 9:58 AMAsk Inkeep
10/16/2025, 9:58 AMAsk Inkeep
10/16/2025, 9:58 AMimport io.permit.sdk.openapi.models.UserCreate;
import io.permit.sdk.openapi.models.UserRead;
UserRead user = permit.api.users.create(
(new UserCreate("auth0|elon") )
.withEmail("<mailto:elonmusk@tesla.com|elonmusk@tesla.com>")
.withFirstName("Elon")
.withLastName("Musk")
) ;
Assigning Roles to API Keys
Once created as users, you can assign roles to these API keys. In Java (2) :
RoleAssignmentRead ra = permit.api.users.assignRole("<mailto:elon@tesla.com|elon@tesla.com>", "admin", "tesla") ;
Or in Node.js (3) :
const response = await permit.api.assignRole(JSON.stringify(assignedRole) ) ;
Where the assignedRole payload would be :
{
role: "role",
tenant: "tenant",
user: "user"
}
This approach allows you to leverage Permit.io's full RBAC capabilities for your API keys, including role assignments at different resource levels and tenant boundaries (4) .Ask Inkeep
10/16/2025, 9:58 AMAlon Boshi
10/16/2025, 10:31 AMPratham Khodwe
10/16/2025, 10:34 AMPratham Khodwe
10/16/2025, 10:34 AMPratham Khodwe
10/16/2025, 10:35 AMAlon Boshi
10/16/2025, 10:37 AMAsk Inkeep
10/16/2025, 10:37 AMAsk Inkeep
10/16/2025, 10:38 AMkey parameter with a naming convention.
When creating users via the SDK or API, the key parameter is "A unique ID by which Permit will identify the user for permission checks" (1) . This key must be "url-friendly (slugified) " and can be "anything for this ID - the user email, a UUID, or anything else as long as it's unique on your end" .
For API key users, you could use a specific prefix in the key. Here's how to create users with distinct identifiers:
*For regular users:*
{
"key": "user|892179821739812389327",
"email": "<mailto:jane@coolcompany.com|jane@coolcompany.com>",
"first_name": "Jane",
"last_name": "Doe"
}
*For API key users, you could use a pattern like:*
• apikey|service-name-123
• service|payment-gateway
• bot|automation-worker
You can also use the attributes field to add metadata that identifies the user type :
{
"key": "apikey|payment-service",
"email": "<mailto:service@example.com|service@example.com>",
"first_name": "Payment",
"last_name": "Service",
"attributes": {
"user_type": "api_key",
"service": "payment_gateway"
}
}
This approach makes it easy to identify API key users at a glance in the User Management screen (2) and when querying users programmatically.Ask Inkeep
10/16/2025, 10:38 AMOr Weis
10/16/2025, 12:21 PM