# 30139: URL not valid for link shortening

Log Type: APPLICATION

Log Level: ERROR

## Description

This error occurs when you send a message with link shortening enabled and one or more URLs in the message body are not valid. To shorten a URL, Twilio requires a valid URL with properly encoded special characters.

### Possible causes

* A URL in the message body contains special characters that were not percent-encoded.
* A URL includes a raw `%` character that is not followed by two hexadecimal digits.
* A path or query string contains non-ASCII or reserved characters such as `ñ` or `=` without encoding.
* A URL is missing a valid scheme or host.

### Possible solutions

* Percent-encode special characters in each URL before you send the message.
* Confirm that every URL includes a valid scheme and host, such as `https://example.com`.
* Encode non-ASCII characters in the path. For example, change `https://example.com/hola/mañana` to `https://example.com/hola/ma%C3%B1ana`.
* Encode reserved query characters when they are part of a parameter value. For example, change `https://example.com/callback?token=abc123==` to `https://example.com/callback?token=abc123%3D%3D`.
* Encode a literal `%` as `%25`. For example, change `https://example.com/path%test` to `https://example.com/path%25test`.
* Test the final message body with link shortening enabled before you send at scale.

#### Additional resources

* [Link Shortening](/docs/messaging/features/link-shortening)
* [Link Shortening Onboarding Guide](/docs/messaging/features/link-shortening/onboarding-guide)
* [Messages resource](/docs/messaging/api/message-resource)
