Skip to main content
Creates a shortened URL from a long URL. Authentication is optional for basic shortening and required for custom slugs.

Endpoint

POST https://www.shorturlx.xyz/api/shorten

Request

Headers
HeaderValueRequired
Content-Typeapplication/jsonYes
AuthorizationBearer YOUR_API_KEYNo (required for customSlug)
Body parameters
url
string
required
The URL to shorten. Must be a valid URL. URLs containing adult content (matching patterns such as porn, xxx, adult, sex, escort, or nsfw) are blocked.
customSlug
string
A custom slug for the short URL, for example my-launch. Requires an authenticated request. Minimum 1 character. Returns 409 if the slug is already taken.

Response

id
string
Unique identifier for the shortened URL record.
shortUrl
string
The complete short URL ready to share, for example https://www.shorturlx.xyz/abc1234.
slug
string
The short code portion of the URL, for example abc1234.
longUrl
string
The original URL that was shortened.
createdAt
string
ISO 8601 timestamp of when the shortened URL was created.

Example request

cURL
curl -X POST "https://www.shorturlx.xyz/api/shorten" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com/very-long-url","customSlug":"my-launch"}'

Example response

{
  "id": "clfg7g3x10000jz08ys42z9q1",
  "shortUrl": "https://www.shorturlx.xyz/my-launch",
  "slug": "my-launch",
  "longUrl": "https://example.com/very-long-url",
  "createdAt": "2023-06-25T15:32:48.000Z"
}

Error codes

StatusDescription
400Invalid request body or URL (including adult content URLs)
401Invalid or revoked API key
409The requested custom slug is already taken
429Rate limit exceeded — see Rate limits
500Internal server error

Build docs developers (and LLMs) love