Project Phil Documentation
Sign in

Create Link

Added in v1.0

POSThttps://api.example.com/api/link

Requires authentication: x-api-key: YOUR_API_KEY

Creates a new shortened link. The link name and destination URL must be supplied in the request body. The link is attributed to API as its creator.

Headers

  • x-api-keystringrequired
    Your API authentication key.
  • Content-Typestringrequired
    Must be application/json.

Body parameters

  • namestringrequired
    The unique name to assign to the shortened link.
  • urlstringrequired
    The destination URL for the shortened link.

Responses

  • 201Created
  • 409Conflict

Request

curl -X POST 'https://api.example.com/api/link' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "google",
  "url": "https://google.com"
}'
const res = await fetch('https://api.example.com/api/link', {
  method: 'POST',
  headers: {
    'x-api-key': 'YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ name: 'google', url: 'https://google.com' })
});
const link = await res.json();
import requests

res = requests.post(
    'https://api.example.com/api/link',
    headers={'x-api-key': 'YOUR_API_KEY'},
    json={'name': 'google', 'url': 'https://google.com'}
)
link = res.json()
$ch = curl_init('https://api.example.com/api/link');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'x-api-key: YOUR_API_KEY',
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'name' => 'google',
    'url' => 'https://google.com'
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$link = json_decode(curl_exec($ch), true);

201 Created

{
  "id": 1,
  "name": "google",
  "url": "https://google.com",
  "count": 0,
  "creator": "API",
  "creatorID": "0",
  "createdAt": 1795400000000
}

409 Conflict

{
  "msg": "A link with that name already exists."
}
Written by !RAB Last updated 1 Dec 2026

Discussion 0

No comments yet. Sign in with Discord to start the conversation.