Key Lifecycle Rules

A KeyLifecycleRule represents a rule that applies to API keys, GPG keys, and SSH keys (also called User Public Keys) based on their inactivity or age.

Keys that have been unused for the specified number of days will be deleted. SSH keys can also be configured to expire after a specified number of days. SSH key expiration applies only to User Public Keys used for inbound SFTP/SSH login, not Remote Server outbound SSH keys.

List Key Lifecycle Rules

Endpoint

GET/key_lifecycle_rules

Return Object

KeyLifecycleRule[]

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Additional Arguments

Example Request

curl https://app.files.com/api/rest/v1/key_lifecycle_rules.json \
  -H 'X-FilesAPI-Key: YOUR_API_KEY'

Example Response

[
  {
    "id": 1,
    "key_type": "gpg",
    "inactivity_days": 12,
    "expiration_days": 365,
    "apply_to_all_workspaces": true,
    "name": "inactive gpg keys",
    "workspace_id": 12
  }
]

Show Key Lifecycle Rule

Endpoint

GET/key_lifecycle_rules/{id}

Return Object

KeyLifecycleRule

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Request Parameters

ParameterDescription
id
int64
Required
Key Lifecycle Rule ID.

Example Request

curl https://app.files.com/api/rest/v1/key_lifecycle_rules/{id}.json \
  -H 'X-FilesAPI-Key: YOUR_API_KEY'

Example Response

{
  "id": 1,
  "key_type": "gpg",
  "inactivity_days": 12,
  "expiration_days": 365,
  "apply_to_all_workspaces": true,
  "name": "inactive gpg keys",
  "workspace_id": 12
}

Create Key Lifecycle Rule

Endpoint

POST/key_lifecycle_rules

Return Object

KeyLifecycleRule

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Request Parameters

ParameterDefaultDescription
apply_to_all_workspaces
boolean
falseIf true, a default-workspace rule also applies to keys in all workspaces.
expiration_days
int64
Number of days after creation before an SSH key expires. Applies only to SSH keys.
key_type
string
Key type for which the rule will apply (gpg, ssh, or api).
Possible values: gpg, ssh, api
inactivity_days
int64
Number of days of inactivity before the rule applies.
name
string
Key Lifecycle Rule name
workspace_id
int64
0Workspace ID. 0 means the default workspace.

Example Request

curl https://app.files.com/api/rest/v1/key_lifecycle_rules.json \
  -X POST \
  -H 'Content-Type: application/json' \
  -d '{"apply_to_all_workspaces":true,"expiration_days":365,"key_type":"gpg","inactivity_days":12,"name":"inactive gpg keys","workspace_id":12}' \
  -H 'X-FilesAPI-Key: YOUR_API_KEY'

Example Response

{
  "id": 1,
  "key_type": "gpg",
  "inactivity_days": 12,
  "expiration_days": 365,
  "apply_to_all_workspaces": true,
  "name": "inactive gpg keys",
  "workspace_id": 12
}

Update Key Lifecycle Rule

Endpoint

PATCH/key_lifecycle_rules/{id}

Return Object

KeyLifecycleRule

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Request Parameters

ParameterDescription
id
int64
Required
Key Lifecycle Rule ID.
apply_to_all_workspaces
boolean
If true, a default-workspace rule also applies to keys in all workspaces.
expiration_days
int64
Number of days after creation before an SSH key expires. Applies only to SSH keys.
key_type
string
Key type for which the rule will apply (gpg, ssh, or api).
Possible values: gpg, ssh, api
inactivity_days
int64
Number of days of inactivity before the rule applies.
name
string
Key Lifecycle Rule name
workspace_id
int64
Workspace ID. 0 means the default workspace.

Example Request

curl https://app.files.com/api/rest/v1/key_lifecycle_rules/{id}.json \
  -X PATCH \
  -H 'Content-Type: application/json' \
  -d '{"apply_to_all_workspaces":true,"expiration_days":365,"key_type":"gpg","inactivity_days":12,"name":"inactive gpg keys","workspace_id":12}' \
  -H 'X-FilesAPI-Key: YOUR_API_KEY'

Example Response

{
  "id": 1,
  "key_type": "gpg",
  "inactivity_days": 12,
  "expiration_days": 365,
  "apply_to_all_workspaces": true,
  "name": "inactive gpg keys",
  "workspace_id": 12
}

Delete Key Lifecycle Rule

Endpoint

DELETE/key_lifecycle_rules/{id}

Return Object

No return value.

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Request Parameters

ParameterDescription
id
int64
Required
Key Lifecycle Rule ID.

Example Request

curl https://app.files.com/api/rest/v1/key_lifecycle_rules/{id}.json \
  -X DELETE \
  -H 'X-FilesAPI-Key: YOUR_API_KEY'

The KeyLifecycleRule Object

Some of the endpoints above return a KeyLifecycleRule object. The attributes of this object are listed below.

AttributeDescription
id
int64
Key Lifecycle Rule ID
key_type
string
Key type for which the rule will apply (gpg, ssh, or api).
Possible values: gpg, ssh, api
inactivity_days
int64
Number of days of inactivity before the rule applies.
expiration_days
int64
Number of days after creation before an SSH key expires. Applies only to SSH keys.
apply_to_all_workspaces
boolean
If true, a default-workspace rule also applies to keys in all workspaces.
name
string
Key Lifecycle Rule name
workspace_id
int64
Workspace ID. 0 means the default workspace.

Example KeyLifecycleRule Object

{
  "id": 1,
  "key_type": "gpg",
  "inactivity_days": 12,
  "expiration_days": 365,
  "apply_to_all_workspaces": true,
  "name": "inactive gpg keys",
  "workspace_id": 12
}