Edit Link
PATCH
https://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.
Headers
-
x-api-keystring requiredYour API authentication key.Example:YOUR_API_KEY
Body parameters
-
idinteger requiredThe database ID of the shortened link to update.Example:123 -
namestring requiredThe new name for the shortened link.Example:example -
urlstring requiredThe new destination URL.Example:https://example.com
Responses
- 200OK
- 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 response = 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 data = await response.json();
console.log(data);
import requests
response = requests.patch(
"https://api.example.com/api/link",
headers={
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"id": 123,
"name": "example",
"url": "https://example.com"
},
)
print(response.json())
<?php
$ch = curl_init('https://api.example.com/api/link');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'x-api-key: YOUR_API_KEY',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => '{
"id": 123,
"name": "example",
"url": "https://example.com"
}',
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
print_r($response);
Response
OK
{
"id": 1,
"name": "example",
"url": "https://example.com",
"count": 0,
"creator": "API",
"creatorID": "0",
"createdAt": 1795400000000
}
Not Found
{
"msg": "That link no longer exists."
}
Conflict
{
"msg": "A link with that name already exists."
}