Skip to main content

Link types

A short link doesn't have to point at a web page. The linkType field lets one short link resolve to an email, phone, or SMS action — the API composes the correct URI for you from structured fields, so you never have to hand-encode a mailto: string. Requires links:write. Available on all tiers.

linkTypeDestinationRequired fieldsOptional fields
urlA web URL (default)longUrl—
mailtoAn email composeemailsubject, body
telA phone dialphone—
smsAn SMS composephone—

When linkType is omitted it defaults to url and behaves exactly like a normal short link.

curl -X POST https://api.short.leonai.io/api/v1/links \
-H "X-API-Key: $LEONAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"linkType": "mailto",
"email": "sales@example.com",
"subject": "Demo request",
"body": "Hi, I would like a demo."
}'

Response (201 Created):

{
"success": true,
"data": {
"id": "link_...",
"shortCode": "a1b2c3",
"shortUrl": "https://short.leonai.io/a1b2c3",
"linkType": "mailto",
"longUrl": "mailto:sales@example.com?subject=Demo%20request&body=Hi%2C%20I%20would%20like%20a%20demo.",
"clicks": 0,
"createdAt": "2026-07-11T12:00:00.000Z"
}
}

The API assembles and percent-encodes the final mailto: URI (shown in longUrl).

curl -X POST https://api.short.leonai.io/api/v1/links \
-H "X-API-Key: $LEONAI_API_KEY" -H "Content-Type: application/json" \
-d '{ "linkType": "tel", "phone": "+15551234567" }'

Use "linkType": "sms" with the same phone field to compose an SMS instead. The composed URI becomes tel:+15551234567 (or sms:+15551234567).

Error codes​

StatusWhen
400Missing the field required for the chosen linkType (e.g. email for mailto, phone for tel/sms), or a malformed email/phone
  • Links — all other link fields and operations
  • API Reference — the full OpenAPI spec and Swagger UI