Edit Link
Added in v1.0
PATCH
https://api.example.com/api/linkRequires 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-keystringrequiredYour API authentication key.Content-TypestringrequiredMust beapplication/json.
Body parameters
idintegerrequiredThe database ID of the shortened link to update.namestringrequiredThe new name for the shortened link. Maximum 100 characters.urlstringrequiredThe new destination URL. Must start withhttp://orhttps://.
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."
}
Discussion 0
Reading is open to everyone. Posting, replying, reacting and reporting require a Discord account — we only receive your public username and avatar.
No comments yet. Sign in with Discord to start the conversation.
Sign in required
Reading is open to everyone. Posting, replying, reacting and reporting require a Discord account — we only receive your public username and avatar.