POST
/api/create
Crea URL
Crea un nuovo URL accorciato.
Crea un URL breve. Puoi scegliere un alias, uno short code personalizzato, una data di scadenza e un numero massimo di utilizzi. Se non indichi custom_code lo short code viene generato automaticamente.
Autenticazione richiesta: header X-Api-Token con il tuo token.
Corpo della richiesta (JSON)
original_url
string
obbligatorio
URL da accorciare. Deve essere http o https e al massimo di 2048 caratteri.
alias
string
opzionale
Alias personalizzato: lettere, numeri, trattini e underscore. Deve essere univoco.
custom_code
string
opzionale
Short code personalizzato (stessi caratteri dell'alias). Deve essere univoco.
expires_at
string
opzionale
Data di scadenza futura, formato YYYY-MM-DD HH:MM:SS o YYYY-MM-DD.
max_uses
integer
opzionale
Numero massimo di utilizzi (intero positivo).
Risposte
201
URL creato
{
"success": true,
"data": {
"original_url": "https://example.com/pagina-molto-lunga",
"short_code": "aB3xYz",
"short_url": "https://short.micheleg.me/s/aB3xYz",
"created_at": "2026-01-15 10:30:00",
"alias": "mio-link",
"expires_at": "2030-12-31 23:59:59",
"max_uses": 100
}
}
400
Dati non validi
{
"success": false,
"error": "Invalid URL format"
}
409
Alias o codice già esistente
{
"success": false,
"error": "Alias already exists"
}
curl -X POST "https://short.micheleg.me/api/create" \
-H "X-Api-Token: YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"original_url":"https://example.com/pagina-molto-lunga","alias":"mio-link","expires_at":"2030-12-31 23:59:59","max_uses":100}'
const response = await fetch('https://short.micheleg.me/api/create', {
method: 'POST',
headers: {
'X-Api-Token': 'YOUR_API_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"original_url": "https://example.com/pagina-molto-lunga",
"alias": "mio-link",
"expires_at": "2030-12-31 23:59:59",
"max_uses": 100
})
});
const data = await response.json();
console.log(data);
import requests
response = requests.request(
"POST",
"https://short.micheleg.me/api/create",
headers={"X-Api-Token": "YOUR_API_TOKEN"},
json={
"original_url": "https://example.com/pagina-molto-lunga",
"alias": "mio-link",
"expires_at": "2030-12-31 23:59:59",
"max_uses": 100
}
)
print(response.json())
<?php
$ch = curl_init('https://short.micheleg.me/api/create');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'X-Api-Token: YOUR_API_TOKEN',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'original_url' => 'https://example.com/pagina-molto-lunga',
'alias' => 'mio-link',
'expires_at' => '2030-12-31 23:59:59',
'max_uses' => 100,
]),
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
print_r($data);
Prova
invia una richiesta reale
© 2026 short.micheleg.me