New-FilesApiKey

Create API Key.

Syntax

New-FilesApiKey [-UserId <System.Int64>] [-Description <System.String>] [-ExpiresAt <System.DateTimeOffset>] -Name <System.String> [-AwsStyleCredentials <System.Boolean>] [-Path <System.String>] [-PermissionSet <System.String>] [-WorkspaceId <System.Int64>] [-Connection <FilesCom.PowerShell.FilesConnection>] [-WorkspaceScope <System.Int64>] [-NoWorkspaceScope] [-WhatIf] [-Confirm] [<CommonParameters>]

Description

Create API Key.

The command supports -WhatIf, which describes the change without sending it to Files.com, and -Confirm, which asks before sending it. It asks for confirmation by default; use -Confirm:$false in scripts that have already decided.

Examples

Example 1: Create API Key

New-FilesApiKey -Name 'My Main API Key' -Description 'example' -ExpiresAt (Get-Date).AddDays(30)

Writes the api key returned.

Example 2: Preview the change

New-FilesApiKey -Name 'My Main API Key' -Description 'example' -ExpiresAt (Get-Date).AddDays(30) -WhatIf

Describes the change without sending anything to Files.com.

Parameters

-UserId

User ID. Provide a value of 0 to operate the current session's user.

  • Type: System.Int64
  • Parameter sets: (All)

-Description

User-supplied description of API key.

  • Type: System.String
  • Parameter sets: (All)

-ExpiresAt

API Key expiration date Give a DateTime from Get-Date, a DateTimeOffset, or ISO 8601 text with an offset such as 2026-01-31T14:00:00Z.

  • Type: System.DateTimeOffset
  • Parameter sets: (All)

-Name

Internal name for the API Key. For your use.

  • Type: System.String
  • Parameter sets: (All) (required)

-AwsStyleCredentials

If true, this API key will be usable with AWS-compatible endpoints, such as our Inbound S3-compatible endpoint.

  • Type: System.Boolean
  • Parameter sets: (All)

-Path

Restricts the file and folder operations made with this key, meaning the files, folders, and file_actions endpoints, to the specified folder and its descendants, including copy and move destinations. For GET /file_migrations/{id}, a key with a path can read only migrations it started. Other endpoints do not apply the path restriction; use the files_only permission set to confine a key to file operations and their supporting lookups. Does not grant access beyond the owning user's permissions. Optional except for office_integration keys, which require a path the owning user can read.

  • Type: System.String
  • Parameter sets: (All)

-PermissionSet

Permissions for this API Key. Keys with the desktop_app permission set only have the ability to do the functions provided in our Desktop App (File and Share Link operations). Keys with the mobile_app permission set can only perform the functions provided by our Mobile App (File and Share Link operations). Keys with the office_integration permission set are auto generated, and automatically expire, to allow users to interact with office integration platforms. Keys with the files_only permission set can use only the files, folders, and file_actions endpoints, excluding the GPG Encrypt and GPG Decrypt file actions, where they perform file operations as a full-access file user in the key's workspace scope, along with GET /file_migrations/{id} and GET /api_key. On the migration lookup, any key with a path can read only migrations it started. Without a path, user-owned keys retain user-scoped access; site-wide Workspace-bound keys can read only migrations whose source and destination are both in their Workspace. Every files_only key is Workspace-bound, including Workspace 0, as is a full-access key in a named Workspace. A full-access site-wide key in the default Workspace retains Site-wide migration access. Migrations outside the caller's visibility return not-found. Keys with files_only cannot use site admin, workspace admin, folder admin, group admin, partner admin, or billing privileges from the owning user. Both GPG file actions and every other endpoint deny them with not-authorized/api-key-only-for-file-operations. Folder-configured GPG encryption and decryption still apply to files uploaded with a files_only key.

  • Type: System.String
  • Parameter sets: (All)

-WorkspaceId

Workspace ID for this API Key. 0 means the default workspace.

  • Type: System.Int64
  • Parameter sets: (All)

-Connection

The connection to use, from Connect-FilesAccount. Defaults to the connection of the -InputObject or -Continuation given, and otherwise to the current runspace's default connection.

  • Type: FilesCom.PowerShell.FilesConnection
  • Parameter sets: (All)

-WorkspaceScope

Runs this command's requests in this workspace, including workspace 0, instead of the connection's or, for an -InputObject, instead of the workspace the object was read in. The connection and the object are unchanged.

  • Type: System.Int64
  • Parameter sets: (All)

-NoWorkspaceScope

Runs this command's requests in no workspace, even if the connection has one. The connection itself is unchanged.

  • Type: System.Management.Automation.SwitchParameter
  • Parameter sets: (All)

-Confirm

Prompts you for confirmation before running the cmdlet.

  • Type: System.Management.Automation.SwitchParameter
  • Confirm impact: High. At the default $ConfirmPreference of High, the command asks before each change; -Confirm:$false runs it without asking.

-WhatIf

Shows what the cmdlet would change without sending anything to Files.com.

  • Type: System.Management.Automation.SwitchParameter

Common Parameters

This cmdlet supports the PowerShell common parameters, such as -Verbose and -ErrorAction.

Inputs

None. The command takes no pipeline input.

Outputs

  • FilesCom.PowerShell.Models.ApiKey: the api key as Files.com returned it.

Notes

Failures are written as error records with IDs such as Files.NotFound or Files.Authentication. Run Get-Help about_FilesCom for connections, paging, errors and previewing changes.