Skip to content

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.

An API key's life, one cmdlet per step New-JIMApiKey creates an API key, which starts enabled and works until its expiry date, if it has one. The full key is returned once, by New-JIMApiKey with -PassThru; Get-JIMApiKey shows only its KeyPrefix. Set-JIMApiKey -Disable disables the key, which is kept but no longer valid, and Set-JIMApiKey -Enable enables it again. Remove-JIMApiKey deletes it, enabled or disabled; deletion is permanent, and requests using the key fail at once. API key New-JIMApiKey -PassThru returns the key once; Get-JIMApiKey shows only KeyPrefix New-JIMApiKey Set-JIMApiKey -Disable Set-JIMApiKey -Enable Remove-JIMApiKey permanent Deletedrequests usingit fail at once Enabledworks untilExpiresAt, if set Disabledkept, but no longer valid An API key's life, one cmdlet per step New-JIMApiKey creates an API key, which starts enabled and works until its expiry date, if it has one. The full key is returned once, by New-JIMApiKey with -PassThru; Get-JIMApiKey shows only its KeyPrefix. Set-JIMApiKey -Disable disables the key, which is kept but no longer valid, and Set-JIMApiKey -Enable enables it again. Remove-JIMApiKey deletes it, enabled or disabled; deletion is permanent, and requests using the key fail at once. New-JIMApiKey API key New-JIMApiKey -PassThru returns the key once; Get-JIMApiKey shows only KeyPrefix Set-JIMApiKey -Disable Set-JIMApiKey -Enable Remove-JIMApiKey permanent Deletedrequests using it fail at once Enabledworks until ExpiresAt, if set Disabledkept, but no longer valid

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

# List (default)
Get-JIMApiKey [-Name <string>]

# ById
Get-JIMApiKey -Id <guid>

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

List all API keys
Get-JIMApiKey
Filter by name
Get-JIMApiKey -Name "CI*"
Get a specific API key by ID
Get-JIMApiKey -Id "a1b2c3d4-e5f6-7890-abcd-ef1234567890"

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

Create a basic API key
New-JIMApiKey -Name "CI Pipeline"
Create with expiry and role assignments
New-JIMApiKey -Name "Monitoring Service" -Description "Read-only monitoring" `
    -RoleIds @(1, 3) -ExpiresAt (Get-Date).AddDays(90)
Create and store the key in a variable
$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 -PassThru is specified. Store it securely; it cannot be retrieved again.
  • Use -RoleIds to scope the key's permissions. A key with no roles has no administrative access.
  • Use -ExpiresAt to 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

Update the name of an API key
Set-JIMApiKey -Id "a1b2c3d4-e5f6-7890-abcd-ef1234567890" -Name "CI Pipeline v2"
Disable an API key
Set-JIMApiKey -Id "a1b2c3d4-e5f6-7890-abcd-ef1234567890" -Disable
Enable a key and set a new expiry
Set-JIMApiKey -Id "a1b2c3d4-e5f6-7890-abcd-ef1234567890" -Enable `
    -ExpiresAt (Get-Date).AddDays(30)
Batch disable all expired keys from pipeline
Get-JIMApiKey | Where-Object { $_.ExpiresAt -and $_.ExpiresAt -lt (Get-Date) } |
    Set-JIMApiKey -Disable

Notes

  • -Enable and -Disable are mutually exclusive; specify only one.
  • Setting -ExpiresAt $null removes the expiry, making the key valid indefinitely (until disabled or deleted).
  • -RoleIds replaces 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

Delete by ID (prompts for confirmation)
Remove-JIMApiKey -Id "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
Force delete without confirmation
Remove-JIMApiKey -Id "a1b2c3d4-e5f6-7890-abcd-ef1234567890" -Force
Pipeline delete from Get-JIMApiKey
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