POST Certificates Import

The POST /Certificates/Import operation imports a certificate provided in the request body into Keyfactor Command. On success, the operation returns HTTP 200 OK with  a message body containing information about the import.

Note:  If Certificate Owner functionality is turned on, the import process verifies that the specified certificate owner is valid and that the user has permission to assign that role. See Certificates in Security Roles and Permissions and the Add Certificate Change Owner section for more information.
Note:  The import operation does not check whether metadataClosed Metadata provides information about a piece of data. It is used to summarize basic information about data, which can make working with the data easier. In Keyfactor Command, the certificate metadata feature allows you to create custom metadata fields that allow you to tag certificates with tracking information about certificates. has changed. If the certificate already exists in Keyfactor Command, the stored metadata is replaced with the metadata supplied in the import request. If the user does not have permission to modify metadata, the operation status indicates that the metadata was not updated.
Tip:  The following permissions (see Security Roles and Claims) are required to use this feature:
/certificates/import/

To update metadata, the user must have:

/certificates/collections/metadata/modify

To assign a certificate owner (when none is set) or to change the existing default certificate owner, the user must have:

/certificates/collections/change_owner/
OR
/certificates/expanded_change_owner/
AND
/security/read/ (in the permission set containing the security role to which the certificate owner will be set)

Table 315: POST Certificates Import Input Parameters

Name In Description
Certificate Body

Required. A string containing the Base64-encoded contents of the certificate to be imported into Keyfactor Command. This may be a certificate with or without associated private key.

The following scenarios are accepted:

  • A Base64-encoded certificate without headers, footers, and line feeds.

  • A Base64-encoded certificate with headers, footers, and line feeds (in the case that the headers, footers, and line feeds are not Base64-encoded).

  • A Base64-encoded certificate with headers, footers, and line feeds that are in the Base64-encoding.

  • A Base64 ASCII (PEM) string.

With PowerShell, for example, you could use the following commands to convert certificates of various types to the appropriate format (referencing $b64Cert in the request body Certificate field).

  • Certificate in PEM format:

    Copy
    $crtCert = Get-Content 'C:\MyPath\MyCertificate.crt'
    $b64Cert = [System.Convert]::ToBase64String(
       [System.Text.Encoding]::ASCII.GetBytes($crtCert)
    )
    Note:  The commands are the same regardless of whether the PEM certificate file contains a private key. The private key is ignored. If the file contains chain certificates, the end entity certificate must precede the chain certificates. Only the first certificate in the file is imported for this certificate type.
  • Certificate in DER format:

    Copy
    $derCert = Get-Content 'C:\MyPath\MyCertificate.der' -Encoding Byte
    $b64Cert = [System.Convert]::ToBase64String($derCert)
  • Certificate in PKCS #12 format:

    Copy
    $pfxCert = Get-Content 'C:\MyPath\MyCertificate.pfx' -Encoding Byte
    $b64Cert = [System.Convert]::ToBase64String($pfxCert)
    Note:  Imports of this certificate type require specifying a Password to decrypt the specified file. Both the certificate and private key are imported.
  • Certificate in PKCS #7 format:

    Copy
    $p7bCert = Get-Content 'C:\MyPath\MyCertificate.p7b' -Encoding Byte
    $b64Cert = [System.Convert]::ToBase64String($p7bCert)
    Note:  The order of the certificates in the certificate package is not important.
Tip:  Use the POST Certificates Analyze operation to confirm that the string you have generated contains the contents that you expect.
Password Body Required in some cases. A string containing the password used to decrypt the file containing the certificate to be imported. This field is required if a certificate of PKCS #12 format is provided in the Certificate field.
Metadata Body

An object containing the certificate metadata that will be associated with the certificate once it is imported. This is provided as a set of key value pairs with the metadata field name in the key and the value in the value. For example:

Copy
"Metadata": {
   "AppOwnerFirstName": "John",
   "AppOwnerLastName": "Smith"
}
Store Ids Body An array of strings indicating the certificate store GUIDs that the imported certificate will be installed into.
Store Types Body

An array of objects indicating the information for the specified store IDs. ClosedShow store type details.

Schedule Body A string containing the time the imported certificate should be scheduled to be installed into the certificate store. The date and time are expressed in ISO 8601 UTC format (YYYY-MM-DDTHH:mm:ss[.fff]Z). For example, 2026-05-19T16:23:01Z.
Owner Role Id Body

An integer indicating the Keyfactor Command reference ID of the security role to assign as the certificate owner.

Note:  To assign a certificate owner, one of OwnerRoleId or OwnerRoleName is required, not both.
Owner Role Name Body

A string containing the name of the security role to assign as the certificate owner. This name must match the existing name of the security role.

The following permissions determine which roles the user can assign as certificate owner:

  • Expanded Change Owner Permission: A user with the Certificates > Expanded Change Owner permission can set the certificate owner to any role within the permission sets they belong to. This permission overrides the Certificates > Collections > Change Owner permission (both Global and Collection level) if both are set.

    Note:  To set the certificate owner using the Expanded Change Owner permission, the user must also have Security > Read permission in the permission set that contains the role being assigned as the certificate owner.
  • Collections > Change Owner Permission:

    This permission allows a user to set the certificate owner to a role they personally hold—but only under the following conditions:

    • No Default Value: The user can set the certificate owner to any role they hold if there is not a default value from the system-wide or enrollment level policy .
    • Default Value: The user can set the certificate owner to any role they hold. If the default value from the policy is not a role held by the acting user, this value will not be used as the owner. The user will still be allowed to add a new owner value.
Note:  To assign a certificate owner, one of OwnerRoleId or OwnerRoleName is required, not both.

Table 316: POST Certificates Import Response Data

Name Description

Import Status

A string indicating the status of the import job indicating, for example, whether the certificate was newly created in Keyfactor Command or already existed in Keyfactor Command and was just updated based on provided private key, metadata, or location information. Possible values include:

  • AddCertUnknown
  • CreatedNew
  • CreatedNewWthKey
  • Exists
  • ExistsAddedKey
  • ExistsAddedKeyMissingOwnerRole
  • ExistsDidNotAddKey (Already exists with key)
  • ExistsDidNotAddKeyMissingOwnerRole
  • ExistsMissingOwnerRole
  • InsufficientEditMetadataPermission
  • InsufficientEditMetadataPermissionsMissingOwnerRole
  • InsufficientKeyPermission
  • NoRetentionPolicy
  • Unknown Template
Note:  An import status of InsufficientEditMetadataPermissionsMissingOwnerRole is not an error state. This indicates the certificate was imported but the user lacked Metadata Modify permissions so the metadata was not changed and the OwnerRole was not updated because one of the following is true:
  • The certificate being imported already has a record in Keyfactor Command with an OwnerRole associated and the current user is not a member of theOwnerRole.

  • The import request did not specify an OwnerRole to save to the certificate.

Note:  An import status of Exists is not an error state. This indicates the certificate being imported already exists in Keyfactor Command, the metadata associated with the certificate has been updated to the metadata supplied in the import request, and the certificate's OwnerRole was set to the OwnerRole provided in the import request, if one was provided.
Invaild Key Stores

An array of objects indicating which key store items failed with some information. ClosedShow key store details.

Job Status An integer indicating the state of all certificate store jobs.