Project Phil Documentation
Sign in

Edit Link

Added in v1.0

PATCHhttps://api.example.com/api/link

Requires authentication: x-api-key: YOUR_API_KEY

Updates the name and destination URL of an existing shortened link. The link ID, new name and new destination URL must be supplied in the request body. The visit count, creator and creation date are not changed. Returns only the id, name and url of the updated link.

Headers

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

Body parameters

  • idintegerrequired
    The database ID of the shortened link to update.
  • namestringrequired
    The new name for the shortened link. Maximum 100 characters.
  • urlstringrequired
    The new destination URL. Must start with http:// or https://.

Tip

The following names are reserved and cannot be used: api, auth, staff, settings, user, users, login, logout, uploads, css, js, logo, links, 403 (case-insensitive).

Responses

  • 200OK
  • 400Bad Request
  • 404Not Found
  • 409Conflict

Request

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

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

200 OK

{
  "id": 123,
  "name": "example",
  "url": "https://example.com"
}

400 Bad Request

{
  "msg": "A link id is required."
}

Other possible msg values:

  • Enter a name and URL.
  • Name must be 100 characters or less.
  • The destination must start with http:// or https://.
  • That name is reserved.

404 Not Found

{
  "msg": "That link no longer exists."
}

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.