Create the link before rendering the message
Generate the destination and call URLMe in the application or worker that prepares the email. Pass only the resulting short URL into the template. This keeps destination complexity and credentials outside the presentation layer.
Preserve signed destinations exactly
Signed download links and account-action URLs often contain long, case-sensitive query strings. Send the complete destination in the JSON request and let URLMe store it server-side; do not trim or decode parameters before shortening.
const result = await fetch("https://api.urlme.link/v1/links", {
method: "POST",
headers: {
Authorization: "Bearer " + process.env.URLME_API_KEY,
"Content-Type": "application/json"
},
body: JSON.stringify({ url: signedDestination })
});
const { data } = await result.json();Match expiration to the action
When the destination should stop working after a known time, provide expiresAt while creating the short link. URLMe permanently returns HTTP 410 after expiration, even if the original destination remains reachable.
Pause first when investigating a bad destination
Pause temporarily if the destination is broken or under review. Resume after correction, or expire the link when it must never deliver again. This separates reversible incident response from permanent retirement.