API Keys¶
The API key cmdlets manage the full lifecycle of API keys used for non-interactive authentication with JIM. You can create, retrieve, update, and delete API keys, as well as control their enabled state and role assignments.
Warning
The full API key value is only visible at creation time. After creation, only the key prefix is returned for identification purposes. Store the key securely immediately; it cannot be retrieved again.
Get-JIMApiKey¶
Retrieves API key information. The full key value is never returned; only the key prefix is shown for identification.
Syntax¶
Parameters¶
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
Id |
guid |
Yes (ById) | The unique identifier (GUID) of a specific API Key to retrieve. Accepts pipeline input by property name. | |
Name |
string |
No (List) | Filters API Keys by name, such as "CI*". Supports wildcards. |
Output¶
Each API Key. The key itself is never returned; KeyPrefix identifies it.
| Property | Type | Description |
|---|---|---|
Id |
guid |
Unique identifier for the API key. |
Name |
string |
Human-readable name for the API key. |
Description |
string |
Optional description of the key's purpose. |
KeyPrefix |
string |
Prefix of the key (e.g., "jim_ak_7f3a") for identification. |
CreatedAt |
datetime |
When the API key was created. |
ExpiresAt |
datetime |
When the key stops working. Always set for a SCIM client's key; empty only for an ordinary API key that never expires. |
LastUsedAt |
datetime |
When the API key was last used for authentication. |
LastUsedFromIp |
string |
IP address from which the key was last used. |
IsEnabled |
bool |
Whether the API key is currently enabled. |
Roles |
object[] |
The roles assigned to this API key. Each has Id, Name, BuiltIn, Created and StaticMemberCount. |
Scope |
string |
What the key may be used for: None for an ordinary API key authorised by its roles, or ScimServiceProvider for a SCIM client's key, which works only on the SCIM endpoint of one Connected System and carries no roles. One of None or ScimServiceProvider. |
ScopeConnectedSystemId |
int |
The Connected System a scoped key works for; empty for an ordinary API key. |
Examples¶
New-JIMApiKey¶
Creates a new API key for non-interactive authentication.
Syntax¶
New-JIMApiKey -Name <string> [-Description <string>] [-RoleIds <int[]>] [-ExpiresAt <datetime>] [-ChangeReason <string>] [-PassThru] [-WhatIf] [-Confirm]
Parameters¶
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
Name |
string |
Yes | The name the API Key is shown by. | |
Description |
string |
No | Optional description of what the API Key is for. | |
RoleIds |
int[] |
No | @() |
The IDs of the Roles the API Key has. |
ExpiresAt |
datetime |
No | When the API Key expires. Omit it for a key that does not expire. | |
ChangeReason |
string |
No | Optional reason for the change, recorded on the audit Activity and shown in the API Key's Configuration Change History. | |
PassThru |
switch |
No | Returns the API Key created, including the key itself. |
Output¶
With -PassThru, the API Key created, with the key itself in Key; otherwise nothing. This is the only time JIM returns the key, so store it securely: without -PassThru it cannot be retrieved.
| Property | Type | Description |
|---|---|---|
Key |
string |
The full API key. This is only returned on creation and cannot be retrieved again. |
Id |
guid |
Unique identifier for the API key. |
Name |
string |
Human-readable name for the API key. |
Description |
string |
Optional description of the key's purpose. |
KeyPrefix |
string |
Prefix of the key (e.g., "jim_ak_7f3a") for identification. |
CreatedAt |
datetime |
When the API key was created. |
ExpiresAt |
datetime |
When the key stops working. Always set for a SCIM client's key; empty only for an ordinary API key that never expires. |
LastUsedAt |
datetime |
When the API key was last used for authentication. |
LastUsedFromIp |
string |
IP address from which the key was last used. |
IsEnabled |
bool |
Whether the API key is currently enabled. |
Roles |
object[] |
The roles assigned to this API key. Each has Id, Name, BuiltIn, Created and StaticMemberCount. |
Scope |
string |
What the key may be used for: None for an ordinary API key authorised by its roles, or ScimServiceProvider for a SCIM client's key, which works only on the SCIM endpoint of one Connected System and carries no roles. One of None or ScimServiceProvider. |
ScopeConnectedSystemId |
int |
The Connected System a scoped key works for; empty for an ordinary API key. |
Examples¶
New-JIMApiKey -Name "Monitoring Service" -Description "Read-only monitoring" `
-RoleIds @(1, 3) -ExpiresAt (Get-Date).AddDays(90)
$key = New-JIMApiKey -Name "Deployment Automation" -PassThru
$key.Key # Full key value; store this securely
Notes¶
- The full API key is returned only in the creation response when
-PassThruis specified. Store it securely; it cannot be retrieved again. - Use
-RoleIdsto scope the key's permissions. A key with no roles has no administrative access. - Use
-ExpiresAtto enforce key rotation policies. Keys without an expiry remain valid until manually disabled or deleted.
Set-JIMApiKey¶
Updates an existing API key's name, description, roles, expiry, or enabled status. The key value itself cannot be changed.
Syntax¶
Set-JIMApiKey -Id <guid> [-Name <string>] [-Description <string>] [-RoleIds <int[]>] [-ExpiresAt <datetime>] [-Enable] [-Disable] [-ChangeReason <string>] [-PassThru] [-WhatIf] [-Confirm]
Parameters¶
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
Id |
guid |
Yes | The unique identifier (GUID) of the API Key to update. Accepts pipeline input by property name. | |
Name |
string |
No | The new name. | |
Description |
string |
No | The new description. | |
RoleIds |
int[] |
No | The IDs of the Roles the API Key has, replacing those it had. Omit it to keep its Roles. | |
ExpiresAt |
datetime |
No | When the API Key expires. $null removes the expiry. |
|
Enable |
switch |
No | Enables the API Key. | |
Disable |
switch |
No | Disables the API Key without removing it. | |
ChangeReason |
string |
No | Optional reason for the change, recorded on the audit Activity and shown in the API Key's Configuration Change History. | |
PassThru |
switch |
No | Returns the API Key as updated. |
Output¶
With -PassThru, the API Key as updated; otherwise nothing.
Properties as under Get-JIMApiKey.
Examples¶
Set-JIMApiKey -Id "a1b2c3d4-e5f6-7890-abcd-ef1234567890" -Name "CI Pipeline v2"
Set-JIMApiKey -Id "a1b2c3d4-e5f6-7890-abcd-ef1234567890" -Enable `
-ExpiresAt (Get-Date).AddDays(30)
Get-JIMApiKey | Where-Object { $_.ExpiresAt -and $_.ExpiresAt -lt (Get-Date) } |
Set-JIMApiKey -Disable
Notes¶
-Enableand-Disableare mutually exclusive; specify only one.- Setting
-ExpiresAt $nullremoves the expiry, making the key valid indefinitely (until disabled or deleted). -RoleIdsreplaces all existing role assignments. To keep current roles, include them in the new array.
Remove-JIMApiKey¶
Permanently deletes an API key. Any requests using this key will fail immediately after deletion.
Syntax¶
# ById (default)
Remove-JIMApiKey -Id <guid> [-ChangeReason <string>] [-Force] [-PassThru] [-WhatIf] [-Confirm]
# ByInputObject
Remove-JIMApiKey -InputObject <PSCustomObject> [-ChangeReason <string>] [-Force] [-PassThru] [-WhatIf] [-Confirm]
It asks for confirmation before it acts: -WhatIf shows what it would do, and -Force or -Confirm:$false skips the prompt.
Parameters¶
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
Id |
guid |
Yes (ById) | The unique identifier (GUID) of the API Key to delete. Accepts pipeline input by property name. | |
InputObject |
PSCustomObject |
Yes (ByInputObject) | The API Key to remove, as Get-JIMApiKey returns it. Accepts pipeline input. |
|
ChangeReason |
string |
No | Optional reason for the change, recorded on the audit Activity and shown in the API Key's Configuration Change History. | |
Force |
switch |
No | Suppresses the confirmation prompt. | |
PassThru |
switch |
No | Returns the API Key as it was before it was removed. |
Output¶
With -PassThru, the API Key as it was before it was removed; otherwise nothing.
Properties as under Get-JIMApiKey.
Examples¶
Get-JIMApiKey | Where-Object { $_.Name -like "temp-*" } | Remove-JIMApiKey -Force
Notes¶
- Deletion is permanent and cannot be undone. A new key must be created if access is needed again.
- Any active sessions or automation using the deleted key will fail immediately.
See also¶
- API Keys: what API keys are, how they're managed, and the surfaces (UI, PowerShell, REST API) for working with them
- Connection: establishing and managing connections to JIM
- Security: security configuration and best practices