# 30118: Private key is invalid

Log Type: APPLICATION

Log Level: ERROR

## Description

Twilio returns this error when the private key uploaded for Link Shortening cannot be parsed. Provide the key in PEM format or in `PKCS #8` format, and make sure it starts with `-----BEGIN PRIVATE KEY-----` and ends with `-----END PRIVATE KEY-----`. Remove any extra newline characters at the beginning or end before you upload the key.

### Possible causes

* The private key is not in `PEM` format or `PKCS #8` format.
* The private key does not start with `-----BEGIN PRIVATE KEY-----` or end with `-----END PRIVATE KEY-----`.
* The private key includes extra newline characters at the beginning or end.

### Possible solutions

* Re-upload a private key in `PEM` or `PKCS #8` format with the required begin and end lines.
* Remove any leading or trailing newline characters before you submit the key.
* In the Console, paste the private key into the Private key input box. When using the API, send the certificate and private key in the `TlsCert` parameter to the Link Shortening domain Certificate subresource.

#### Additional resources

* [Link Shortening](/docs/messaging/features/link-shortening)
* [Link Shortening onboarding guide](/docs/messaging/features/link-shortening/onboarding-guide)
* [Messaging API Overview](/docs/messaging/api)
