Table of Contents

Introduction

Welcome to the URLVanish API! Our API allows you to integrate URL shortening capabilities directly into your applications. Create shortened URLs programmatically while maintaining the same privacy-focused approach that makes URLVanish unique.

Base URL: All API requests should be made to https://urlvanish.com/create_api.php

Authentication

URLVanish API supports optional API key authentication. Authenticated requests link shortened URLs to your account so you can manage them from your dashboard.

  1. Create an account at URLVanish
  2. Log in and go to your Dashboard
  3. Generate an API key from the API Keys section
  4. Include your API key in the request header

Authentication Header

Authorization: Bearer YOUR_API_KEY
Note: Authentication is optional. You can create short URLs without an API key, but they won't be linked to your account and won't appear in your dashboard.

Rate Limits

To ensure fair usage for all users, we implement the following rate limits:

Create Short URL

POST https://urlvanish.com/create_api.php

Creates a new shortened URL.

Request Headers

Header Required Description
Content-Type Yes Must be application/json
Authorization No Bearer token for authenticated requests: Bearer YOUR_API_KEY

Request Body (JSON)

Parameter Type Required Description
originalUrl string Yes The URL to shorten
customAlias string No Custom alias for the short URL (letters, numbers, dashes, underscores)

Example Request

{
  "originalUrl": "https://example.com/very-long-url",
  "customAlias": "my-custom-link"
}

Success Response

{
  "status": "success",
  "alias": "https://urlvanish.com/my-custom-link",
  "originalUrl": "https://example.com/very-long-url"
}
Note: When using a valid API key, the response also includes an authenticated_as field with your username, confirming the URL was linked to your account.

Authenticated Response

{
  "status": "success",
  "alias": "https://urlvanish.com/my-custom-link",
  "originalUrl": "https://example.com/very-long-url",
  "authenticated_as": "your_username"
}

Error Response

{
  "status": "error",
  "message": "Missing required parameter: originalUrl."
}

Get URL Information Coming Soon

This endpoint is planned for a future release. It will allow you to retrieve information about a shortened URL including click statistics.

Delete URL Coming Soon

This endpoint is planned for a future release. It will allow you to delete shortened URLs via the API. Currently, you can manage your URLs from your dashboard.

List URLs Coming Soon

This endpoint is planned for a future release. It will allow you to list all URLs created by your account with pagination and sorting. Currently, you can view your URLs from your dashboard.

Error Handling

The API uses HTTP response codes alongside a JSON response to indicate success or failure.

Status Code Description
200 Success — URL created
401 Unauthorized — Invalid or inactive API key
500 Internal Server Error

Error Response Format

{
  "status": "error",
  "message": "Description of what went wrong"
}

Common Errors

Message Cause
Missing required parameter: originalUrl. The originalUrl field is missing or empty in the request body
Invalid or inactive API key. The Bearer token is not a valid API key or has been deleted
Alias already exists. Please choose a different alias. The customAlias you requested is already taken
Invalid HTTP method. Please use POST. The request was not a POST request

Code Examples

cURL

curl -X POST https://urlvanish.com/create_api.php \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "originalUrl": "https://example.com/long-url",
    "customAlias": "my-link"
  }'

cURL (without authentication)

curl -X POST https://urlvanish.com/create_api.php \
  -H "Content-Type: application/json" \
  -d '{
    "originalUrl": "https://example.com/long-url"
  }'

JavaScript

const response = await fetch('https://urlvanish.com/create_api.php', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    originalUrl: 'https://example.com/long-url',
    customAlias: 'my-link'
  })
});

const data = await response.json();
console.log(data);
// { status: "success", alias: "https://urlvanish.com/my-link", originalUrl: "...", authenticated_as: "..." }

Python

import requests

url = "https://urlvanish.com/create_api.php"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}
data = {
    "originalUrl": "https://example.com/long-url",
    "customAlias": "my-link"
}

response = requests.post(url, json=data, headers=headers)
print(response.json())
# {'status': 'success', 'alias': 'https://urlvanish.com/my-link', 'originalUrl': '...', 'authenticated_as': '...'}

PHP

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://urlvanish.com/create_api.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer YOUR_API_KEY',
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'originalUrl' => 'https://example.com/long-url',
    'customAlias' => 'my-link'
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);

print_r($data);
// Array ( [status] => success [alias] => https://urlvanish.com/my-link [originalUrl] => ... [authenticated_as] => ... )
Need Help? If you have questions about the API or need assistance with integration, please contact our support team through the contact form.