Keys

Overview

This API has been available since 1.6.0

Cryptographic keys are used in signing and verifying JWTs and verifying responses for third party identity providers. It is more likely you will interact with keys using the FusionAuth UI in the Key Master menu. If you do have a need to retrieve or manage keys using the API the following APIs have been provided.

Retrieve a Key

This API is used to retrieve a single Key by unique Id or all of the configured Keys.

Request

API Key Authentication
Retrieve all of the Keys
GET /api/key
API Key Authentication
Retrieve a Key by Id
GET /api/key/{keyId}

Request Parameters

keyIdUUIDrequired

The unique Id of the Key to retrieve.

Response

The response for this API contains either a single Key or all of the Keys. When you call this API with an Id the response will contain a single Key. When you call this API without an Id the response will contain all of the Keys. Both response types are defined below along with an example JSON response.

Response Codes
Code Description
200 The request was successful. The response will contain a JSON body.
400 The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present.
401 You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication.
404 The object you requested doesn't exist. The response will be empty.
500 There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty.
503 The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body.

Response Body

key.algorithmString

The algorithm used to generate the key.

key.certificateString

The RSA or EC X.509 certificate. This field is omitted for HMAC key types.

key.certificateInformationMap<String, Object

The RSA or EC certificate information. This field is omitted for HMAC key types.

key.certificateInformation.issuerString

The issuer of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.md5FingerprintString

The md5 fingerprint of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.serialNumberString

The serial number of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.sha1FingerprintString

The SHA-1 fingerprint of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.sha1ThumbprintString

The SHA-1 thumbprint of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.sha256FingerprintString

The SHA-256 fingerprint of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.sha256ThumbprintString

The SHA-256 thumbprint of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.subjectString

The subject of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.validFromInteger

The UNIX time in milliseconds marking the start of the RSA or EC certificate validity period. This field is omitted for HMAC key types.

key.certificateInformation.validToInteger

The UNIX time in milliseconds marking the expiration RSA or EC certificate. This field is omitted for HMAC key types.

key.expirationInstantInteger

The instant marking the expiration RSA or EC certificate. This field is omitted for HMAC key types.

key.hasPrivateKeyBoolean

Because the private key will never be returned in the API response, this value will indicate if the private key is stored in FusionAuth. This field is omitted for HMAC key types.

key.idUUID

The Id of the Key.

key.insertInstantLong

The instant that the key was added to the FusionAuth database.

key.issuerString

The issuer of the RSA or EC certificate. This field is omitted for HMAC key types.

key.kidString

The key identifier ‘kid’.

key.lastUpdateInstantLong

The instant that the key was updated in the FusionAuth database.

key.lengthString

The length of the RSA or EC certificate. This field is omitted for HMAC key types.

key.nameString

The name of the key.

key.publicKeyString

The RSA or EC certificate public key. This field is omitted for HMAC key types.

key.typeString

The key type. The possible values are:

  • EC
  • RSA
  • HMAC

Example HMAC Key Response JSON

{
  "key": {
    "algorithm": "HS256",
    "id": "092dbedc-30af-4149-9c61-b578f2c72f59",
    "insertInstant": 1562171137000,
    "kid": "10d51735a5",
    "lastUpdateInstant": 1595361143101,
    "name": "OpenID Connect compliant HMAC using SHA-256",
    "type": "HMAC"
  }
}

Example RSA Key Response JSON

{
  "key": {
    "algorithm": "RS256",
    "certificate": "-----BEGIN CERTIFICATE-----\nMIICrjCCAZagAwIBAQIQeA4dW+47Q7KuyNuZuZrcTjANBgkqhkiG9w0BAQsFADAT\nMREwDwYDVQQDEwhhY21lLmNvbTAeFw0xOTA3MDMyMTI0MzJaFw0yOTA3MDMyMTI0\nMzJaMBMxETAPBgNVBAMTCGFjbWUuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\nMIIBCgKCAQEAnbNGwtU33S4vbipGeIwe/DhLEfc5FaEOHK4WeQ3QF8zZGyI09bNQ\ndkp8uNTFfVehIgmvYHmJWPeaNrYK//qjWAsSvYYoytj1j4BywI8uLSjt8QvzaoFU\nMOi1cBbXM2586R7yTRm7jMk91MLM101zkrf1cmFdRUwTpeJjw66XG3JlTGZCmZsJ\nG7m6+nbe5LHt4CiufmJHujGeFzgwby3jXZtuK1y3ua3380Fv95JyG3TucnMwEw5E\nYQ8Q+dZzNC8OSaKrgmnN0gWdsJ7P7vu6lMy6sXKhvcxo1p+tXywYPFJahxA+rZDG\n16RLbUppCx10q8tIcFKeAyl4eywzBaBLxwIDAQABMA0GCSqGSIb3DQEBCwUAA4IB\nAQBbsHWIBDwW1hFEin0D5BK/rwpCIZ4jlJ9PON4q0rF/tl9+pSzTqMeEqU0NMlJ7\nXm2O5U0i8Sy8Lhemo9qYCZ76qEiHFZwQBmNAC4de92KMcw4Q7q5CVjTGv3X+Avlg\n/c+I+zJLO/IJlzhOvHj+iCeBZDznt6/KlFfXA9EvlznxqZCQHSf2f94UlvBmqbVY\nOfXE5+OQ3URyNyh88g9yClSb4hzu1lmzevZ/AVbe2kTjZQQWB0TmqPg/6SS+nhsa\nuAMK1kSlSK9t6CPz/L7olJeAi7G/PZPaYG1gIFVFaBnYM0rwagQGtPMi1uCERCKr\nkUlBh6gSyN7SGJBvWEh6+zZF\n-----END CERTIFICATE-----",
    "certificateInformation": {
      "issuer": "CN=acme.com",
      "md5Fingerprint": "FC:36:CD:0B:9C:B7:62:F0:A9:16:AE:72:8E:F8:7D:D8",
      "serialNumber": "78:0E:1D:5B:EE:3B:43:B2:AE:C8:DB:99:B9:9A:DC:4E",
      "sha1Fingerprint": "CD:A9:80:5F:4D:37:EB:CD:B4:45:42:DF:76:35:15:E9:89:21:61:B6",
      "sha1Thumbprint": "zamAX0036820RULfdjUV6YkhYbY",
      "sha256Fingerprint": "33:7C:CB:4C:23:3B:F5:22:49:2F:68:C5:FA:D1:6E:3C:72:54:CB:3C:E6:D1:70:08:55:FC:43:24:9A:98:05:CF",
      "sha256Thumbprint": "M3zLTCM79SJJL2jF-tFuPHJUyzzm0XAIVfxDJJqYBc8",
      "subject": "CN=acme.com",
      "validFrom": 1562189072183,
      "validTo": 1877808272183
    },
    "expirationInstant": 1877808272183,
    "hasPrivateKey": false,
    "id": "780e1d5b-ee3b-43b2-aec8-db99b99adc4e",
    "insertInstant": 1562189072183,
    "issuer": "acme.com",
    "kid": "zamAX0036820RULfdjUV6YkhYbY",
    "lastUpdateInstant": 1595361143101,
    "length": 2048,
    "name": "SHA-256 with RSA",
    "publicKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnbNGwtU33S4vbipGeIwe\n/DhLEfc5FaEOHK4WeQ3QF8zZGyI09bNQdkp8uNTFfVehIgmvYHmJWPeaNrYK//qj\nWAsSvYYoytj1j4BywI8uLSjt8QvzaoFUMOi1cBbXM2586R7yTRm7jMk91MLM101z\nkrf1cmFdRUwTpeJjw66XG3JlTGZCmZsJG7m6+nbe5LHt4CiufmJHujGeFzgwby3j\nXZtuK1y3ua3380Fv95JyG3TucnMwEw5EYQ8Q+dZzNC8OSaKrgmnN0gWdsJ7P7vu6\nlMy6sXKhvcxo1p+tXywYPFJahxA+rZDG16RLbUppCx10q8tIcFKeAyl4eywzBaBL\nxwIDAQAB\n-----END PUBLIC KEY-----",
    "type": "RSA"
  }
}

Example EC Key Response JSON

{
  "key": {
    "algorithm": "ES256",
    "certificate": "-----BEGIN CERTIFICATE-----\nMIIBJzCBy6ADAgEBAhEAwUtQ5YaLTb6fPAKM0FFbETAMBggqhkjOPQQDAgUAMBMx\nETAPBgNVBAMTCGFjbWUuY29tMB4XDTIxMTAwMjEzNDE1MVoXDTMxMTAwMjEzNDE1\nMVowEzERMA8GA1UEAxMIYWNtZS5jb20wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNC\nAARPysdu/AKSICtkZa9hlBGb7vJHJ0GHWYXEeyTYDCPd2XoT5icVAZQ5GVU1q2WV\nEaVJRmlFuGqWElvYLIRYrce2MAwGCCqGSM49BAMCBQADSQAwRgIhAJCXC5Ys25Wk\nYXeC1bWjyt71p8Yn1B//DZo+SzQrBVF+AiEA3u6an0m+wsO1dnNN1wtXdUsa5Avo\nOjME4ZLJHhtGQ1I=\n-----END CERTIFICATE-----",
    "certificateInformation": {
      "issuer": "CN=acme.com",
      "md5Fingerprint": "E5:50:70:3A:88:56:7C:BE:CB:FA:50:29:19:B5:CE:2D",
      "serialNumber": "00:C1:4B:50:E5:86:8B:4D:BE:9F:3C:02:8C:D0:51:5B:11",
      "sha1Fingerprint": "2F:22:15:AC:7C:2A:67:E8:F3:AB:87:97:3A:E0:84:58:79:A3:35:7F",
      "sha1Thumbprint": "LyIVrHwqZ-jzq4eXOuCEWHmjNX8",
      "sha256Fingerprint": "D5:B0:B5:5E:07:1D:2B:84:A8:7C:5F:89:B7:74:62:2F:8C:57:A8:66:A1:D5:A2:F1:A9:94:70:8F:D3:0D:64:0F",
      "sha256Thumbprint": "1bC1XgcdK4SofF-Jt3RiL4xXqGah1aLxqZRwj9MNZA8",
      "subject": "CN=acme.com",
      "validFrom": 1633182111000,
      "validTo": 1948714911000
    },
    "expirationInstant": 1948714911000,
    "hasPrivateKey": true,
    "id": "c14b50e5-868b-4dbe-9f3c-028cd0515b11",
    "insertInstant": 1633182111648,
    "issuer": "acme.com",
    "kid": "LyIVrHwqZ-jzq4eXOuCEWHmjNX8",
    "lastUpdateInstant": 1633182111648,
    "length": 256,
    "name": "ECDSA using P-256 curve and SHA-256",
    "publicKey": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAET8rHbvwCkiArZGWvYZQRm+7yRydB\nh1mFxHsk2Awj3dl6E+YnFQGUORlVNatllRGlSUZpRbhqlhJb2CyEWK3Htg==\n-----END PUBLIC KEY-----",
    "type": "EC"
  }
}

Response Body

keys[x]Array

The list of Key objects.

keys[x].algorithmString

The algorithm used to generate the key.

keys[x].certificateString

The RSA or EC X.509 certificate. This field is omitted for HMAC key types.

keys[x].certificateInformationMap<String, Object

The RSA or EC certificate information. This field is omitted for HMAC key types.

keys[x].certificateInformation.issuerString

The issuer of the RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].certificateInformation.md5FingerprintString

The md5 fingerprint of the RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].certificateInformation.serialNumberString

The serial number of the RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].certificateInformation.sha1FingerprintString

The SHA-1 fingerprint of the RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].certificateInformation.sha1ThumbprintString

The SHA-1 thumbprint of the RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].certificateInformation.sha256FingerprintString

The SHA-256 fingerprint of the RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].certificateInformation.sha256ThumbprintString

The SHA-256 thumbprint of the RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].certificateInformation.subjectString

The subject of the RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].certificateInformation.validFromInteger

The UNIX time in milliseconds marking the start of the RSA or EC certificate validity period. This field is omitted for HMAC key types.

keys[x].certificateInformation.validToInteger

The UNIX time in milliseconds marking the expiration RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].expirationInstantInteger

The instant marking the expiration RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].hasPrivateKeyBoolean

Because the private key will never be returned in the API response, this value will indicate if the private key is stored in FusionAuth. This field is omitted for HMAC key types.

keys[x].idUUID

The Id of the Key.

keys[x].insertInstantLong

The instant that the key was added to the FusionAuth database.

keys[x].issuerString

The issuer of the RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].kidString

The key identifier ‘kid’.

keys[x].lastUpdateInstantLong

The instant that the key was updated in the FusionAuth database.

keys[x].lengthString

The length of the RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].nameString

The name of the key.

keys[x].publicKeyString

The RSA or EC certificate public key. This field is omitted for HMAC key types.

keys[x].typeString

The key type. The possible values are:

  • EC
  • RSA
  • HMAC

Update a Key

This API method is used to update an existing Key.

Only the name of the Key may be changed; all other fields will remain the same. If you need to update a Key with a new certificate, algorithm or other attributes, please Import a Key.

For example, if you have a Key with an associated expiring certificate, you’ll need to follow the steps similar to those outlined in the JWT signing key rotation documentation:

  • Import this key, keypair or certificate into FusionAuth. This will create a new Key entity in FusionAuth.
  • Update the appropriate configuration with this new Key (JWT signing configuration, SAML validation configuration, etc).
  • Once the new Key is configured for use, remove the expired, previous Key.

Note that validation rules will prevent you from removing an in-use key.

API Key Authentication
Update the Key with the given Id
PUT /api/key/{keyId}

Request Parameters

keyIdUUIDrequired

The unique Id of the Key to update.

Request Body

key.nameStringrequired

The name of the Key. It must be unique among all Keys.

Example Request JSON

{
  "key": {
    "name": "OpenID Connect compliant HMAC using SHA-256"
  }
}

Response

The response for this API contains the Key that was updated.

Response Codes
Code Description
200 The request was successful. The response will contain a JSON body.
400 The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present.
401 You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication.
404 The object you are trying to update doesn't exist. The response will be empty.
500 There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty.
503 The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body.

Response Body

key.algorithmString

The algorithm used to generate the key.

key.certificateString

The RSA or EC X.509 certificate. This field is omitted for HMAC key types.

key.certificateInformationMap<String, Object

The RSA or EC certificate information. This field is omitted for HMAC key types.

key.certificateInformation.issuerString

The issuer of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.md5FingerprintString

The md5 fingerprint of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.serialNumberString

The serial number of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.sha1FingerprintString

The SHA-1 fingerprint of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.sha1ThumbprintString

The SHA-1 thumbprint of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.sha256FingerprintString

The SHA-256 fingerprint of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.sha256ThumbprintString

The SHA-256 thumbprint of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.subjectString

The subject of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.validFromInteger

The UNIX time in milliseconds marking the start of the RSA or EC certificate validity period. This field is omitted for HMAC key types.

key.certificateInformation.validToInteger

The UNIX time in milliseconds marking the expiration RSA or EC certificate. This field is omitted for HMAC key types.

key.expirationInstantInteger

The instant marking the expiration RSA or EC certificate. This field is omitted for HMAC key types.

key.hasPrivateKeyBoolean

Because the private key will never be returned in the API response, this value will indicate if the private key is stored in FusionAuth. This field is omitted for HMAC key types.

key.idUUID

The Id of the Key.

key.insertInstantLong

The instant that the key was added to the FusionAuth database.

key.issuerString

The issuer of the RSA or EC certificate. This field is omitted for HMAC key types.

key.kidString

The key identifier ‘kid’.

key.lastUpdateInstantLong

The instant that the key was updated in the FusionAuth database.

key.lengthString

The length of the RSA or EC certificate. This field is omitted for HMAC key types.

key.nameString

The name of the key.

key.publicKeyString

The RSA or EC certificate public key. This field is omitted for HMAC key types.

key.typeString

The key type. The possible values are:

  • EC
  • RSA
  • HMAC

Example HMAC Key Response JSON

{
  "key": {
    "algorithm": "HS256",
    "id": "092dbedc-30af-4149-9c61-b578f2c72f59",
    "insertInstant": 1562171137000,
    "kid": "10d51735a5",
    "lastUpdateInstant": 1595361143101,
    "name": "OpenID Connect compliant HMAC using SHA-256",
    "type": "HMAC"
  }
}

Example RSA Key Response JSON

{
  "key": {
    "algorithm": "RS256",
    "certificate": "-----BEGIN CERTIFICATE-----\nMIICrjCCAZagAwIBAQIQeA4dW+47Q7KuyNuZuZrcTjANBgkqhkiG9w0BAQsFADAT\nMREwDwYDVQQDEwhhY21lLmNvbTAeFw0xOTA3MDMyMTI0MzJaFw0yOTA3MDMyMTI0\nMzJaMBMxETAPBgNVBAMTCGFjbWUuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\nMIIBCgKCAQEAnbNGwtU33S4vbipGeIwe/DhLEfc5FaEOHK4WeQ3QF8zZGyI09bNQ\ndkp8uNTFfVehIgmvYHmJWPeaNrYK//qjWAsSvYYoytj1j4BywI8uLSjt8QvzaoFU\nMOi1cBbXM2586R7yTRm7jMk91MLM101zkrf1cmFdRUwTpeJjw66XG3JlTGZCmZsJ\nG7m6+nbe5LHt4CiufmJHujGeFzgwby3jXZtuK1y3ua3380Fv95JyG3TucnMwEw5E\nYQ8Q+dZzNC8OSaKrgmnN0gWdsJ7P7vu6lMy6sXKhvcxo1p+tXywYPFJahxA+rZDG\n16RLbUppCx10q8tIcFKeAyl4eywzBaBLxwIDAQABMA0GCSqGSIb3DQEBCwUAA4IB\nAQBbsHWIBDwW1hFEin0D5BK/rwpCIZ4jlJ9PON4q0rF/tl9+pSzTqMeEqU0NMlJ7\nXm2O5U0i8Sy8Lhemo9qYCZ76qEiHFZwQBmNAC4de92KMcw4Q7q5CVjTGv3X+Avlg\n/c+I+zJLO/IJlzhOvHj+iCeBZDznt6/KlFfXA9EvlznxqZCQHSf2f94UlvBmqbVY\nOfXE5+OQ3URyNyh88g9yClSb4hzu1lmzevZ/AVbe2kTjZQQWB0TmqPg/6SS+nhsa\nuAMK1kSlSK9t6CPz/L7olJeAi7G/PZPaYG1gIFVFaBnYM0rwagQGtPMi1uCERCKr\nkUlBh6gSyN7SGJBvWEh6+zZF\n-----END CERTIFICATE-----",
    "certificateInformation": {
      "issuer": "CN=acme.com",
      "md5Fingerprint": "FC:36:CD:0B:9C:B7:62:F0:A9:16:AE:72:8E:F8:7D:D8",
      "serialNumber": "78:0E:1D:5B:EE:3B:43:B2:AE:C8:DB:99:B9:9A:DC:4E",
      "sha1Fingerprint": "CD:A9:80:5F:4D:37:EB:CD:B4:45:42:DF:76:35:15:E9:89:21:61:B6",
      "sha1Thumbprint": "zamAX0036820RULfdjUV6YkhYbY",
      "sha256Fingerprint": "33:7C:CB:4C:23:3B:F5:22:49:2F:68:C5:FA:D1:6E:3C:72:54:CB:3C:E6:D1:70:08:55:FC:43:24:9A:98:05:CF",
      "sha256Thumbprint": "M3zLTCM79SJJL2jF-tFuPHJUyzzm0XAIVfxDJJqYBc8",
      "subject": "CN=acme.com",
      "validFrom": 1562189072183,
      "validTo": 1877808272183
    },
    "expirationInstant": 1877808272183,
    "hasPrivateKey": false,
    "id": "780e1d5b-ee3b-43b2-aec8-db99b99adc4e",
    "insertInstant": 1562189072183,
    "issuer": "acme.com",
    "kid": "zamAX0036820RULfdjUV6YkhYbY",
    "lastUpdateInstant": 1595361143101,
    "length": 2048,
    "name": "SHA-256 with RSA",
    "publicKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnbNGwtU33S4vbipGeIwe\n/DhLEfc5FaEOHK4WeQ3QF8zZGyI09bNQdkp8uNTFfVehIgmvYHmJWPeaNrYK//qj\nWAsSvYYoytj1j4BywI8uLSjt8QvzaoFUMOi1cBbXM2586R7yTRm7jMk91MLM101z\nkrf1cmFdRUwTpeJjw66XG3JlTGZCmZsJG7m6+nbe5LHt4CiufmJHujGeFzgwby3j\nXZtuK1y3ua3380Fv95JyG3TucnMwEw5EYQ8Q+dZzNC8OSaKrgmnN0gWdsJ7P7vu6\nlMy6sXKhvcxo1p+tXywYPFJahxA+rZDG16RLbUppCx10q8tIcFKeAyl4eywzBaBL\nxwIDAQAB\n-----END PUBLIC KEY-----",
    "type": "RSA"
  }
}

Example EC Key Response JSON

{
  "key": {
    "algorithm": "ES256",
    "certificate": "-----BEGIN CERTIFICATE-----\nMIIBJzCBy6ADAgEBAhEAwUtQ5YaLTb6fPAKM0FFbETAMBggqhkjOPQQDAgUAMBMx\nETAPBgNVBAMTCGFjbWUuY29tMB4XDTIxMTAwMjEzNDE1MVoXDTMxMTAwMjEzNDE1\nMVowEzERMA8GA1UEAxMIYWNtZS5jb20wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNC\nAARPysdu/AKSICtkZa9hlBGb7vJHJ0GHWYXEeyTYDCPd2XoT5icVAZQ5GVU1q2WV\nEaVJRmlFuGqWElvYLIRYrce2MAwGCCqGSM49BAMCBQADSQAwRgIhAJCXC5Ys25Wk\nYXeC1bWjyt71p8Yn1B//DZo+SzQrBVF+AiEA3u6an0m+wsO1dnNN1wtXdUsa5Avo\nOjME4ZLJHhtGQ1I=\n-----END CERTIFICATE-----",
    "certificateInformation": {
      "issuer": "CN=acme.com",
      "md5Fingerprint": "E5:50:70:3A:88:56:7C:BE:CB:FA:50:29:19:B5:CE:2D",
      "serialNumber": "00:C1:4B:50:E5:86:8B:4D:BE:9F:3C:02:8C:D0:51:5B:11",
      "sha1Fingerprint": "2F:22:15:AC:7C:2A:67:E8:F3:AB:87:97:3A:E0:84:58:79:A3:35:7F",
      "sha1Thumbprint": "LyIVrHwqZ-jzq4eXOuCEWHmjNX8",
      "sha256Fingerprint": "D5:B0:B5:5E:07:1D:2B:84:A8:7C:5F:89:B7:74:62:2F:8C:57:A8:66:A1:D5:A2:F1:A9:94:70:8F:D3:0D:64:0F",
      "sha256Thumbprint": "1bC1XgcdK4SofF-Jt3RiL4xXqGah1aLxqZRwj9MNZA8",
      "subject": "CN=acme.com",
      "validFrom": 1633182111000,
      "validTo": 1948714911000
    },
    "expirationInstant": 1948714911000,
    "hasPrivateKey": true,
    "id": "c14b50e5-868b-4dbe-9f3c-028cd0515b11",
    "insertInstant": 1633182111648,
    "issuer": "acme.com",
    "kid": "LyIVrHwqZ-jzq4eXOuCEWHmjNX8",
    "lastUpdateInstant": 1633182111648,
    "length": 256,
    "name": "ECDSA using P-256 curve and SHA-256",
    "publicKey": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAET8rHbvwCkiArZGWvYZQRm+7yRydB\nh1mFxHsk2Awj3dl6E+YnFQGUORlVNatllRGlSUZpRbhqlhJb2CyEWK3Htg==\n-----END PUBLIC KEY-----",
    "type": "EC"
  }
}

Delete a Key

This API is used to delete a Key.

API Key Authentication
Delete the Key with the given Id
DELETE /api/key/{keyId}

Request Parameters

keyIdUUIDrequired

The unique Id of the Key to delete.

Response

This API does not return a JSON response body.

Response Codes
Code Description
200 The request was successful.
400 The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present.
401 You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication.
404 The object you requested doesn't exist. The response will be empty.
500 There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty.
503 The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body.

Search for Keys

This API has been available since 1.45.0

This API is used to search for Keys and may be called using the GET or POST HTTP methods. Examples of each are provided below. The POST method is provided to allow for a richer request object without worrying about exceeding the maximum length of a URL. Calling this API with either the GET or POST HTTP method will provide the same search results given the same query parameters.

Request

API Key Authentication
Search for Keys
GET /api/key/search?algorithm=RS256&name={name}&type=RSA

Request Parameters

algorithmString

The algorithm used to generate the key.

The possible values are:

  • ES256 - ECDSA using P-256 curve and SHA-256 hash algorithm
  • ES384 - ECDSA using P-384 curve and SHA-384 hash algorithm
  • ES512 - ECDSA using P-521 curve and SHA-512 hash algorithm
  • RS256 - RSA using SHA-256 hash algorithm
  • RS384 - RSA using SHA-384 hash algorithm
  • RS512 - RSA using SHA-512 hash algorithm
  • HS256 - HMAC using SHA-256 hash algorithm
  • HS384 - HMAC using SHA-384 hash algorithm
  • HS512 - HMAC using SHA-512 hash algorithm
nameString

The case-insensitive string to search for in the Key name. This can contain wildcards using the asterisk character (*). If no wildcards are present, the search criteria will be interpreted as *value*.

numberOfResultsIntegerDefaults to 25

The number of results to return from the search.

orderByStringDefaults to name ASC

The field to order the search results as well as an order direction.

The possible values are:

  • algorithm - the algorithm used to generate the Key. ** Not all keys have an algorithm, null values are treated as smaller than all other values. ** The possible values are: See algorithm .
  • expiration - the expiration instant of the Key. ** Not all keys have an expiration value, null values are treated as smaller than all other values.
  • id - the UUID of the Key
  • insertInstant - the instant when the Key was created
  • name - the Key name
  • type - the Key type ** The possible values are: See type .

The order direction is optional. Possible values of the order direction are ASC or DESC. If omitted, the default sort order is ASC.

For example, to order the results by the insert instant in a descending order, use insertInstant DESC.

startRowIntegerDefaults to 0

The offset into the total results. In order to paginate the results, increment this value by the numberOfResults for subsequent requests.

For example, if the total search results are greater than the page size designated by numberOfResults , set this value to 25 to retrieve results 26-50, assuming the default page size.

typeString

The key type. The possible values are:

  • EC
  • RSA
  • HMAC
API Key Authentication
Search for Keys
POST /api/key/search

When calling the API using a POST request you will send the search criteria in a JSON request body.

Request Body

search.algorithmString

The algorithm used to generate the key.

The possible values are:

  • ES256 - ECDSA using P-256 curve and SHA-256 hash algorithm
  • ES384 - ECDSA using P-384 curve and SHA-384 hash algorithm
  • ES512 - ECDSA using P-521 curve and SHA-512 hash algorithm
  • RS256 - RSA using SHA-256 hash algorithm
  • RS384 - RSA using SHA-384 hash algorithm
  • RS512 - RSA using SHA-512 hash algorithm
  • HS256 - HMAC using SHA-256 hash algorithm
  • HS384 - HMAC using SHA-384 hash algorithm
  • HS512 - HMAC using SHA-512 hash algorithm
search.nameString

The case-insensitive string to search for in the Key name. This can contain wildcards using the asterisk character (*). If no wildcards are present, the search criteria will be interpreted as *value*.

search.numberOfResultsIntegerDefaults to 25

The number of results to return from the search.

search.orderByStringDefaults to name ASC

The field to order the search results as well as an order direction.

The possible values are:

  • algorithm - the algorithm used to generate the Key. ** Not all keys have an algorithm, null values are treated as smaller than all other values. ** The possible values are: See search.algorithm .
  • expiration - the expiration instant of the Key. ** Not all keys have an expiration value, null values are treated as smaller than all other values.
  • id - the UUID of the Key
  • insertInstant - the instant when the Key was created
  • name - the Key name
  • type - the Key type ** The possible values are: See search.type .

The order direction is optional. Possible values of the order direction are ASC or DESC. If omitted, the default sort order is ASC.

For example, to order the results by the insert instant in a descending order, use insertInstant DESC.

search.startRowIntegerDefaults to 0

The offset into the total results. In order to paginate the results, increment this value by the numberOfResults for subsequent requests.

For example, if the total search results are greater than the page size designated by numberOfResults , set this value to 25 to retrieve results 26-50, assuming the default page size.

search.typeString

The key type. The possible values are:

  • EC
  • RSA
  • HMAC

Example Request JSON

{
  "search": {
    "algorithm": "RS256",
    "name": "forum",
    "numberOfResults": 25,
    "orderBy": "insertInstant",
    "startRow": 0,
    "type": "RSA"
  }
}

Response

The response for this API contains the Keys matching the search criteria in paginated format and the total number of results matching the search criteria.

Response Codes
Code Description
200 The request was successful. The response will contain a JSON body.
400 The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present.
401 You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication.
500 There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty.

Response Body

keys[x]Array

The list of Key objects.

keys[x].algorithmString

The algorithm used to generate the key.

keys[x].certificateString

The RSA or EC X.509 certificate. This field is omitted for HMAC key types.

keys[x].certificateInformationMap<String, Object

The RSA or EC certificate information. This field is omitted for HMAC key types.

keys[x].certificateInformation.issuerString

The issuer of the RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].certificateInformation.md5FingerprintString

The md5 fingerprint of the RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].certificateInformation.serialNumberString

The serial number of the RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].certificateInformation.sha1FingerprintString

The SHA-1 fingerprint of the RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].certificateInformation.sha1ThumbprintString

The SHA-1 thumbprint of the RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].certificateInformation.sha256FingerprintString

The SHA-256 fingerprint of the RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].certificateInformation.sha256ThumbprintString

The SHA-256 thumbprint of the RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].certificateInformation.subjectString

The subject of the RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].certificateInformation.validFromInteger

The UNIX time in milliseconds marking the start of the RSA or EC certificate validity period. This field is omitted for HMAC key types.

keys[x].certificateInformation.validToInteger

The UNIX time in milliseconds marking the expiration RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].expirationInstantInteger

The instant marking the expiration RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].hasPrivateKeyBoolean

Because the private key will never be returned in the API response, this value will indicate if the private key is stored in FusionAuth. This field is omitted for HMAC key types.

keys[x].idUUID

The Id of the Key.

keys[x].insertInstantLong

The instant that the key was added to the FusionAuth database.

keys[x].issuerString

The issuer of the RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].kidString

The key identifier ‘kid’.

keys[x].lastUpdateInstantLong

The instant that the key was updated in the FusionAuth database.

keys[x].lengthString

The length of the RSA or EC certificate. This field is omitted for HMAC key types.

keys[x].nameString

The name of the key.

keys[x].publicKeyString

The RSA or EC certificate public key. This field is omitted for HMAC key types.

keys[x].typeString

The key type. The possible values are:

  • EC
  • RSA
  • HMAC

Generate a Key

This API is used to generate a new Key.

API Key Authentication
Generate a new Key with a randomly generated Id
POST /api/key/generate
API Key Authentication
Generate a new Key with the provided unique Id
POST /api/key/generate/{keyId}

Request Parameters

keyIdUUIDDefaults to secure random UUID

The Id to use for the new key. If not specified a secure random UUID will be generated.

Request Body

key.algorithmStringrequired

The algorithm used to generate the Key. The following values represent algorithms supported by FusionAuth:

  • ES256 - ECDSA using P-256 curve and SHA-256 hash algorithm
  • ES384 - ECDSA using P-384 curve and SHA-384 hash algorithm
  • ES512 - ECDSA using P-521 curve and SHA-512 hash algorithm
  • RS256 - RSA using SHA-256 hash algorithm
  • RS384 - RSA using SHA-384 hash algorithm
  • RS512 - RSA using SHA-512 hash algorithm
  • HS256 - HMAC using SHA-256 hash algorithm
  • HS384 - HMAC using SHA-384 hash algorithm
  • HS512 - HMAC using SHA-512 hash algorithm
key.issuerString

The issuer of the RSA or EC certificate.

If omitted, this value will default to the value of tenant.issuer on the default tenant. For HMAC keys, this field does not apply and will be ignored if specified, and no default value will be set.

key.nameStringrequired

The name of the Key.

key.lengthString

The length of the RSA or EC certificate. This field is required when generating RSA key types.

For RSA, possible values are: 2048, 3072 or 4096.

For EC, possible values are: 256, 384, or 521.

Example Request JSON

{
  "key": {
    "algorithm": "RS256",
    "issuer": "piedpiper.com",
    "name": "SHA-256 with RSA",
    "length": 2048
  }
}

Response

The response for this API contains the Key that was generated.

Response Codes
Code Description
200 The request was successful. The response will contain a JSON body.
400 The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present.
401 You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication.
500 There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty.
503 The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body.

Response Body

key.algorithmString

The algorithm used to generate the key.

key.certificateString

The RSA or EC X.509 certificate. This field is omitted for HMAC key types.

key.certificateInformationMap<String, Object

The RSA or EC certificate information. This field is omitted for HMAC key types.

key.certificateInformation.issuerString

The issuer of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.md5FingerprintString

The md5 fingerprint of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.serialNumberString

The serial number of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.sha1FingerprintString

The SHA-1 fingerprint of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.sha1ThumbprintString

The SHA-1 thumbprint of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.sha256FingerprintString

The SHA-256 fingerprint of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.sha256ThumbprintString

The SHA-256 thumbprint of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.subjectString

The subject of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.validFromInteger

The UNIX time in milliseconds marking the start of the RSA or EC certificate validity period. This field is omitted for HMAC key types.

key.certificateInformation.validToInteger

The UNIX time in milliseconds marking the expiration RSA or EC certificate. This field is omitted for HMAC key types.

key.expirationInstantInteger

The instant marking the expiration RSA or EC certificate. This field is omitted for HMAC key types.

key.hasPrivateKeyBoolean

Because the private key will never be returned in the API response, this value will indicate if the private key is stored in FusionAuth. This field is omitted for HMAC key types.

key.idUUID

The Id of the Key.

key.insertInstantLong

The instant that the key was added to the FusionAuth database.

key.issuerString

The issuer of the RSA or EC certificate. This field is omitted for HMAC key types.

key.kidString

The key identifier ‘kid’.

key.lastUpdateInstantLong

The instant that the key was updated in the FusionAuth database.

key.lengthString

The length of the RSA or EC certificate. This field is omitted for HMAC key types.

key.nameString

The name of the key.

key.publicKeyString

The RSA or EC certificate public key. This field is omitted for HMAC key types.

key.typeString

The key type. The possible values are:

  • EC
  • RSA
  • HMAC

Example HMAC Key Response JSON

{
  "key": {
    "algorithm": "HS256",
    "id": "092dbedc-30af-4149-9c61-b578f2c72f59",
    "insertInstant": 1562171137000,
    "kid": "10d51735a5",
    "lastUpdateInstant": 1595361143101,
    "name": "OpenID Connect compliant HMAC using SHA-256",
    "type": "HMAC"
  }
}

Example RSA Key Response JSON

{
  "key": {
    "algorithm": "RS256",
    "certificate": "-----BEGIN CERTIFICATE-----\nMIICrjCCAZagAwIBAQIQeA4dW+47Q7KuyNuZuZrcTjANBgkqhkiG9w0BAQsFADAT\nMREwDwYDVQQDEwhhY21lLmNvbTAeFw0xOTA3MDMyMTI0MzJaFw0yOTA3MDMyMTI0\nMzJaMBMxETAPBgNVBAMTCGFjbWUuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\nMIIBCgKCAQEAnbNGwtU33S4vbipGeIwe/DhLEfc5FaEOHK4WeQ3QF8zZGyI09bNQ\ndkp8uNTFfVehIgmvYHmJWPeaNrYK//qjWAsSvYYoytj1j4BywI8uLSjt8QvzaoFU\nMOi1cBbXM2586R7yTRm7jMk91MLM101zkrf1cmFdRUwTpeJjw66XG3JlTGZCmZsJ\nG7m6+nbe5LHt4CiufmJHujGeFzgwby3jXZtuK1y3ua3380Fv95JyG3TucnMwEw5E\nYQ8Q+dZzNC8OSaKrgmnN0gWdsJ7P7vu6lMy6sXKhvcxo1p+tXywYPFJahxA+rZDG\n16RLbUppCx10q8tIcFKeAyl4eywzBaBLxwIDAQABMA0GCSqGSIb3DQEBCwUAA4IB\nAQBbsHWIBDwW1hFEin0D5BK/rwpCIZ4jlJ9PON4q0rF/tl9+pSzTqMeEqU0NMlJ7\nXm2O5U0i8Sy8Lhemo9qYCZ76qEiHFZwQBmNAC4de92KMcw4Q7q5CVjTGv3X+Avlg\n/c+I+zJLO/IJlzhOvHj+iCeBZDznt6/KlFfXA9EvlznxqZCQHSf2f94UlvBmqbVY\nOfXE5+OQ3URyNyh88g9yClSb4hzu1lmzevZ/AVbe2kTjZQQWB0TmqPg/6SS+nhsa\nuAMK1kSlSK9t6CPz/L7olJeAi7G/PZPaYG1gIFVFaBnYM0rwagQGtPMi1uCERCKr\nkUlBh6gSyN7SGJBvWEh6+zZF\n-----END CERTIFICATE-----",
    "certificateInformation": {
      "issuer": "CN=acme.com",
      "md5Fingerprint": "FC:36:CD:0B:9C:B7:62:F0:A9:16:AE:72:8E:F8:7D:D8",
      "serialNumber": "78:0E:1D:5B:EE:3B:43:B2:AE:C8:DB:99:B9:9A:DC:4E",
      "sha1Fingerprint": "CD:A9:80:5F:4D:37:EB:CD:B4:45:42:DF:76:35:15:E9:89:21:61:B6",
      "sha1Thumbprint": "zamAX0036820RULfdjUV6YkhYbY",
      "sha256Fingerprint": "33:7C:CB:4C:23:3B:F5:22:49:2F:68:C5:FA:D1:6E:3C:72:54:CB:3C:E6:D1:70:08:55:FC:43:24:9A:98:05:CF",
      "sha256Thumbprint": "M3zLTCM79SJJL2jF-tFuPHJUyzzm0XAIVfxDJJqYBc8",
      "subject": "CN=acme.com",
      "validFrom": 1562189072183,
      "validTo": 1877808272183
    },
    "expirationInstant": 1877808272183,
    "hasPrivateKey": false,
    "id": "780e1d5b-ee3b-43b2-aec8-db99b99adc4e",
    "insertInstant": 1562189072183,
    "issuer": "acme.com",
    "kid": "zamAX0036820RULfdjUV6YkhYbY",
    "lastUpdateInstant": 1595361143101,
    "length": 2048,
    "name": "SHA-256 with RSA",
    "publicKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnbNGwtU33S4vbipGeIwe\n/DhLEfc5FaEOHK4WeQ3QF8zZGyI09bNQdkp8uNTFfVehIgmvYHmJWPeaNrYK//qj\nWAsSvYYoytj1j4BywI8uLSjt8QvzaoFUMOi1cBbXM2586R7yTRm7jMk91MLM101z\nkrf1cmFdRUwTpeJjw66XG3JlTGZCmZsJG7m6+nbe5LHt4CiufmJHujGeFzgwby3j\nXZtuK1y3ua3380Fv95JyG3TucnMwEw5EYQ8Q+dZzNC8OSaKrgmnN0gWdsJ7P7vu6\nlMy6sXKhvcxo1p+tXywYPFJahxA+rZDG16RLbUppCx10q8tIcFKeAyl4eywzBaBL\nxwIDAQAB\n-----END PUBLIC KEY-----",
    "type": "RSA"
  }
}

Example EC Key Response JSON

{
  "key": {
    "algorithm": "ES256",
    "certificate": "-----BEGIN CERTIFICATE-----\nMIIBJzCBy6ADAgEBAhEAwUtQ5YaLTb6fPAKM0FFbETAMBggqhkjOPQQDAgUAMBMx\nETAPBgNVBAMTCGFjbWUuY29tMB4XDTIxMTAwMjEzNDE1MVoXDTMxMTAwMjEzNDE1\nMVowEzERMA8GA1UEAxMIYWNtZS5jb20wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNC\nAARPysdu/AKSICtkZa9hlBGb7vJHJ0GHWYXEeyTYDCPd2XoT5icVAZQ5GVU1q2WV\nEaVJRmlFuGqWElvYLIRYrce2MAwGCCqGSM49BAMCBQADSQAwRgIhAJCXC5Ys25Wk\nYXeC1bWjyt71p8Yn1B//DZo+SzQrBVF+AiEA3u6an0m+wsO1dnNN1wtXdUsa5Avo\nOjME4ZLJHhtGQ1I=\n-----END CERTIFICATE-----",
    "certificateInformation": {
      "issuer": "CN=acme.com",
      "md5Fingerprint": "E5:50:70:3A:88:56:7C:BE:CB:FA:50:29:19:B5:CE:2D",
      "serialNumber": "00:C1:4B:50:E5:86:8B:4D:BE:9F:3C:02:8C:D0:51:5B:11",
      "sha1Fingerprint": "2F:22:15:AC:7C:2A:67:E8:F3:AB:87:97:3A:E0:84:58:79:A3:35:7F",
      "sha1Thumbprint": "LyIVrHwqZ-jzq4eXOuCEWHmjNX8",
      "sha256Fingerprint": "D5:B0:B5:5E:07:1D:2B:84:A8:7C:5F:89:B7:74:62:2F:8C:57:A8:66:A1:D5:A2:F1:A9:94:70:8F:D3:0D:64:0F",
      "sha256Thumbprint": "1bC1XgcdK4SofF-Jt3RiL4xXqGah1aLxqZRwj9MNZA8",
      "subject": "CN=acme.com",
      "validFrom": 1633182111000,
      "validTo": 1948714911000
    },
    "expirationInstant": 1948714911000,
    "hasPrivateKey": true,
    "id": "c14b50e5-868b-4dbe-9f3c-028cd0515b11",
    "insertInstant": 1633182111648,
    "issuer": "acme.com",
    "kid": "LyIVrHwqZ-jzq4eXOuCEWHmjNX8",
    "lastUpdateInstant": 1633182111648,
    "length": 256,
    "name": "ECDSA using P-256 curve and SHA-256",
    "publicKey": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAET8rHbvwCkiArZGWvYZQRm+7yRydB\nh1mFxHsk2Awj3dl6E+YnFQGUORlVNatllRGlSUZpRbhqlhJb2CyEWK3Htg==\n-----END PUBLIC KEY-----",
    "type": "EC"
  }
}

Import a Key

This API is used to import an existing Key into FusionAuth.

For RSA pairs, possible key lengths are: 1024 (only valid when importing a public key for signature verification), 2048, 3072 or 4096.

For EC pairs, possible key lengths are: 256, 384, or 521.

API Key Authentication
Import an existing Key with a randomly generated Id
POST /api/key/import
API Key Authentication
Import an existing Key with the provided unique Id
POST /api/key/import/{keyId}

Request Parameters

keyIdUUID

The unique Id of the Key. Use if you want to specify a known UUID. This is useful if you are migrating from an existing system or will otherwise depend on having a known key Id.

Request Body

key.algorithmString

The algorithm used to generate the Key. The algorithm will be inferred if it is not passed explicitly. The following values represent algorithms supported by FusionAuth:

  • ES256 - ECDSA using P-256 curve and SHA-256 hash algorithm
  • ES384 - ECDSA using P-384 curve and SHA-384 hash algorithm
  • ES512 - ECDSA using P-521 curve and SHA-512 hash algorithm
  • RS256 - RSA using SHA-256 hash algorithm
  • RS384 - RSA using SHA-384 hash algorithm
  • RS512 - RSA using SHA-512 hash algorithm
  • HS256 - HMAC using SHA-256 hash algorithm
  • HS384 - HMAC using SHA-384 hash algorithm
  • HS512 - HMAC using SHA-512 hash algorithm
key.certificateString

The certificate to import. The publicKey will be extracted from the certificate.

key.kidString

The Key identifier ‘kid’. When this value is omitted, one will be generated.

key.nameStringrequired

The name of the Key. It must be unique among all Keys.

key.publicKeyString

The Key public key. Required if importing an RSA or EC key and a certificate is not provided.

key.privateKeyString

The Key private key. Optional if importing an RSA or EC key. If the key is only to be used for token validation, only a public key is necessary and this field may be omitted.

key.secretString

The Key secret. This field is required if importing an HMAC key type.

key.typeString

The Key type. This field is required if importing an HMAC key type, or if importing a public key / private key pair. The possible values are:

  • EC
  • RSA
  • HMAC

Example Request JSON

{
  "key": {
    "name": "SHA-256 with RSA",
    "kid": "zamAX0036820RULfdjUV6YkhYbY",
    "certificate": "MIICrjCCAZagAwIBAQIQeA4dW+47Q7KuyNuZuZrcTjANBgkqhkiG9w0BAQsFADATMREwDwYDVQQDEwhhY21lLmNvbTAeFw0xOTA3MDMyMTI0MzJaFw0yOTA3MDMyMTI0MzJaMBMxETAPBgNVBAMTCGFjbWUuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnbNGwtU33S4vbipGeIwe/DhLEfc5FaEOHK4WeQ3QF8zZGyI09bNQdkp8uNTFfVehIgmvYHmJWPeaNrYK//qjWAsSvYYoytj1j4BywI8uLSjt8QvzaoFUMOi1cBbXM2586R7yTRm7jMk91MLM101zkrf1cmFdRUwTpeJjw66XG3JlTGZCmZsJG7m6+nbe5LHt4CiufmJHujGeFzgwby3jXZtuK1y3ua3380Fv95JyG3TucnMwEw5EYQ8Q+dZzNC8OSaKrgmnN0gWdsJ7P7vu6lMy6sXKhvcxo1p+tXywYPFJahxA+rZDG16RLbUppCx10q8tIcFKeAyl4eywzBaBLxwIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQBbsHWIBDwW1hFEin0D5BK/rwpCIZ4jlJ9PON4q0rF/tl9+pSzTqMeEqU0NMlJ7Xm2O5U0i8Sy8Lhemo9qYCZ76qEiHFZwQBmNAC4de92KMcw4Q7q5CVjTGv3X+Avlg/c+I+zJLO/IJlzhOvHj+iCeBZDznt6/KlFfXA9EvlznxqZCQHSf2f94UlvBmqbVYOfXE5+OQ3URyNyh88g9yClSb4hzu1lmzevZ/AVbe2kTjZQQWB0TmqPg/6SS+nhsauAMK1kSlSK9t6CPz/L7olJeAi7G/PZPaYG1gIFVFaBnYM0rwagQGtPMi1uCERCKrkUlBh6gSyN7SGJBvWEh6+zZF"
  }
}

Response

The response for this API contains the Key that was imported.

Response Codes
Code Description
200 The request was successful. The response will contain a JSON body.
400 The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present.
401 You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication.
500 There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty.
503 The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body.

Response Body

key.algorithmString

The algorithm used to generate the key.

key.certificateString

The RSA or EC X.509 certificate. This field is omitted for HMAC key types.

key.certificateInformationMap<String, Object

The RSA or EC certificate information. This field is omitted for HMAC key types.

key.certificateInformation.issuerString

The issuer of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.md5FingerprintString

The md5 fingerprint of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.serialNumberString

The serial number of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.sha1FingerprintString

The SHA-1 fingerprint of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.sha1ThumbprintString

The SHA-1 thumbprint of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.sha256FingerprintString

The SHA-256 fingerprint of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.sha256ThumbprintString

The SHA-256 thumbprint of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.subjectString

The subject of the RSA or EC certificate. This field is omitted for HMAC key types.

key.certificateInformation.validFromInteger

The UNIX time in milliseconds marking the start of the RSA or EC certificate validity period. This field is omitted for HMAC key types.

key.certificateInformation.validToInteger

The UNIX time in milliseconds marking the expiration RSA or EC certificate. This field is omitted for HMAC key types.

key.expirationInstantInteger

The instant marking the expiration RSA or EC certificate. This field is omitted for HMAC key types.

key.hasPrivateKeyBoolean

Because the private key will never be returned in the API response, this value will indicate if the private key is stored in FusionAuth. This field is omitted for HMAC key types.

key.idUUID

The Id of the Key.

key.insertInstantLong

The instant that the key was added to the FusionAuth database.

key.issuerString

The issuer of the RSA or EC certificate. This field is omitted for HMAC key types.

key.kidString

The key identifier ‘kid’.

key.lastUpdateInstantLong

The instant that the key was updated in the FusionAuth database.

key.lengthString

The length of the RSA or EC certificate. This field is omitted for HMAC key types.

key.nameString

The name of the key.

key.publicKeyString

The RSA or EC certificate public key. This field is omitted for HMAC key types.

key.typeString

The key type. The possible values are:

  • EC
  • RSA
  • HMAC

Example HMAC Key Response JSON

{
  "key": {
    "algorithm": "HS256",
    "id": "092dbedc-30af-4149-9c61-b578f2c72f59",
    "insertInstant": 1562171137000,
    "kid": "10d51735a5",
    "lastUpdateInstant": 1595361143101,
    "name": "OpenID Connect compliant HMAC using SHA-256",
    "type": "HMAC"
  }
}

Example RSA Key Response JSON

{
  "key": {
    "algorithm": "RS256",
    "certificate": "-----BEGIN CERTIFICATE-----\nMIICrjCCAZagAwIBAQIQeA4dW+47Q7KuyNuZuZrcTjANBgkqhkiG9w0BAQsFADAT\nMREwDwYDVQQDEwhhY21lLmNvbTAeFw0xOTA3MDMyMTI0MzJaFw0yOTA3MDMyMTI0\nMzJaMBMxETAPBgNVBAMTCGFjbWUuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\nMIIBCgKCAQEAnbNGwtU33S4vbipGeIwe/DhLEfc5FaEOHK4WeQ3QF8zZGyI09bNQ\ndkp8uNTFfVehIgmvYHmJWPeaNrYK//qjWAsSvYYoytj1j4BywI8uLSjt8QvzaoFU\nMOi1cBbXM2586R7yTRm7jMk91MLM101zkrf1cmFdRUwTpeJjw66XG3JlTGZCmZsJ\nG7m6+nbe5LHt4CiufmJHujGeFzgwby3jXZtuK1y3ua3380Fv95JyG3TucnMwEw5E\nYQ8Q+dZzNC8OSaKrgmnN0gWdsJ7P7vu6lMy6sXKhvcxo1p+tXywYPFJahxA+rZDG\n16RLbUppCx10q8tIcFKeAyl4eywzBaBLxwIDAQABMA0GCSqGSIb3DQEBCwUAA4IB\nAQBbsHWIBDwW1hFEin0D5BK/rwpCIZ4jlJ9PON4q0rF/tl9+pSzTqMeEqU0NMlJ7\nXm2O5U0i8Sy8Lhemo9qYCZ76qEiHFZwQBmNAC4de92KMcw4Q7q5CVjTGv3X+Avlg\n/c+I+zJLO/IJlzhOvHj+iCeBZDznt6/KlFfXA9EvlznxqZCQHSf2f94UlvBmqbVY\nOfXE5+OQ3URyNyh88g9yClSb4hzu1lmzevZ/AVbe2kTjZQQWB0TmqPg/6SS+nhsa\nuAMK1kSlSK9t6CPz/L7olJeAi7G/PZPaYG1gIFVFaBnYM0rwagQGtPMi1uCERCKr\nkUlBh6gSyN7SGJBvWEh6+zZF\n-----END CERTIFICATE-----",
    "certificateInformation": {
      "issuer": "CN=acme.com",
      "md5Fingerprint": "FC:36:CD:0B:9C:B7:62:F0:A9:16:AE:72:8E:F8:7D:D8",
      "serialNumber": "78:0E:1D:5B:EE:3B:43:B2:AE:C8:DB:99:B9:9A:DC:4E",
      "sha1Fingerprint": "CD:A9:80:5F:4D:37:EB:CD:B4:45:42:DF:76:35:15:E9:89:21:61:B6",
      "sha1Thumbprint": "zamAX0036820RULfdjUV6YkhYbY",
      "sha256Fingerprint": "33:7C:CB:4C:23:3B:F5:22:49:2F:68:C5:FA:D1:6E:3C:72:54:CB:3C:E6:D1:70:08:55:FC:43:24:9A:98:05:CF",
      "sha256Thumbprint": "M3zLTCM79SJJL2jF-tFuPHJUyzzm0XAIVfxDJJqYBc8",
      "subject": "CN=acme.com",
      "validFrom": 1562189072183,
      "validTo": 1877808272183
    },
    "expirationInstant": 1877808272183,
    "hasPrivateKey": false,
    "id": "780e1d5b-ee3b-43b2-aec8-db99b99adc4e",
    "insertInstant": 1562189072183,
    "issuer": "acme.com",
    "kid": "zamAX0036820RULfdjUV6YkhYbY",
    "lastUpdateInstant": 1595361143101,
    "length": 2048,
    "name": "SHA-256 with RSA",
    "publicKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnbNGwtU33S4vbipGeIwe\n/DhLEfc5FaEOHK4WeQ3QF8zZGyI09bNQdkp8uNTFfVehIgmvYHmJWPeaNrYK//qj\nWAsSvYYoytj1j4BywI8uLSjt8QvzaoFUMOi1cBbXM2586R7yTRm7jMk91MLM101z\nkrf1cmFdRUwTpeJjw66XG3JlTGZCmZsJG7m6+nbe5LHt4CiufmJHujGeFzgwby3j\nXZtuK1y3ua3380Fv95JyG3TucnMwEw5EYQ8Q+dZzNC8OSaKrgmnN0gWdsJ7P7vu6\nlMy6sXKhvcxo1p+tXywYPFJahxA+rZDG16RLbUppCx10q8tIcFKeAyl4eywzBaBL\nxwIDAQAB\n-----END PUBLIC KEY-----",
    "type": "RSA"
  }
}

Example EC Key Response JSON

{
  "key": {
    "algorithm": "ES256",
    "certificate": "-----BEGIN CERTIFICATE-----\nMIIBJzCBy6ADAgEBAhEAwUtQ5YaLTb6fPAKM0FFbETAMBggqhkjOPQQDAgUAMBMx\nETAPBgNVBAMTCGFjbWUuY29tMB4XDTIxMTAwMjEzNDE1MVoXDTMxMTAwMjEzNDE1\nMVowEzERMA8GA1UEAxMIYWNtZS5jb20wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNC\nAARPysdu/AKSICtkZa9hlBGb7vJHJ0GHWYXEeyTYDCPd2XoT5icVAZQ5GVU1q2WV\nEaVJRmlFuGqWElvYLIRYrce2MAwGCCqGSM49BAMCBQADSQAwRgIhAJCXC5Ys25Wk\nYXeC1bWjyt71p8Yn1B//DZo+SzQrBVF+AiEA3u6an0m+wsO1dnNN1wtXdUsa5Avo\nOjME4ZLJHhtGQ1I=\n-----END CERTIFICATE-----",
    "certificateInformation": {
      "issuer": "CN=acme.com",
      "md5Fingerprint": "E5:50:70:3A:88:56:7C:BE:CB:FA:50:29:19:B5:CE:2D",
      "serialNumber": "00:C1:4B:50:E5:86:8B:4D:BE:9F:3C:02:8C:D0:51:5B:11",
      "sha1Fingerprint": "2F:22:15:AC:7C:2A:67:E8:F3:AB:87:97:3A:E0:84:58:79:A3:35:7F",
      "sha1Thumbprint": "LyIVrHwqZ-jzq4eXOuCEWHmjNX8",
      "sha256Fingerprint": "D5:B0:B5:5E:07:1D:2B:84:A8:7C:5F:89:B7:74:62:2F:8C:57:A8:66:A1:D5:A2:F1:A9:94:70:8F:D3:0D:64:0F",
      "sha256Thumbprint": "1bC1XgcdK4SofF-Jt3RiL4xXqGah1aLxqZRwj9MNZA8",
      "subject": "CN=acme.com",
      "validFrom": 1633182111000,
      "validTo": 1948714911000
    },
    "expirationInstant": 1948714911000,
    "hasPrivateKey": true,
    "id": "c14b50e5-868b-4dbe-9f3c-028cd0515b11",
    "insertInstant": 1633182111648,
    "issuer": "acme.com",
    "kid": "LyIVrHwqZ-jzq4eXOuCEWHmjNX8",
    "lastUpdateInstant": 1633182111648,
    "length": 256,
    "name": "ECDSA using P-256 curve and SHA-256",
    "publicKey": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAET8rHbvwCkiArZGWvYZQRm+7yRydB\nh1mFxHsk2Awj3dl6E+YnFQGUORlVNatllRGlSUZpRbhqlhJb2CyEWK3Htg==\n-----END PUBLIC KEY-----",
    "type": "EC"
  }
}