Create Redirect
curl --request POST \
--url https://api.lightsage.com/v2/library/redirects \
--header 'Content-Type: application/json' \
--header 'X-Lightsage-Api-Key: <api-key>' \
--data '
{
"from_url": "<string>",
"to_url": "<string>",
"title": "<string>",
"live_on": "2023-12-25",
"task_id": "<string>"
}
'import requests
url = "https://api.lightsage.com/v2/library/redirects"
payload = {
"from_url": "<string>",
"to_url": "<string>",
"title": "<string>",
"live_on": "2023-12-25",
"task_id": "<string>"
}
headers = {
"X-Lightsage-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Lightsage-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
from_url: '<string>',
to_url: '<string>',
title: '<string>',
live_on: '2023-12-25',
task_id: '<string>'
})
};
fetch('https://api.lightsage.com/v2/library/redirects', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.lightsage.com/v2/library/redirects",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'from_url' => '<string>',
'to_url' => '<string>',
'title' => '<string>',
'live_on' => '2023-12-25',
'task_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Lightsage-Api-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.lightsage.com/v2/library/redirects"
payload := strings.NewReader("{\n \"from_url\": \"<string>\",\n \"to_url\": \"<string>\",\n \"title\": \"<string>\",\n \"live_on\": \"2023-12-25\",\n \"task_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Lightsage-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.lightsage.com/v2/library/redirects")
.header("X-Lightsage-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"from_url\": \"<string>\",\n \"to_url\": \"<string>\",\n \"title\": \"<string>\",\n \"live_on\": \"2023-12-25\",\n \"task_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lightsage.com/v2/library/redirects")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Lightsage-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"from_url\": \"<string>\",\n \"to_url\": \"<string>\",\n \"title\": \"<string>\",\n \"live_on\": \"2023-12-25\",\n \"task_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"title": "<string>",
"from_url": "<string>",
"to_url": "<string>",
"live_on": "2023-12-25",
"task_id": "<string>",
"added_at": "<string>",
"updated_at": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Library
Create Redirect
Records a redirect that is live on your site, so the Library can show whether it helps. The old address must be on your own site. This does not change your site. Sending the same request again returns the redirect it already made, so a retry is safe; a different to_url for an old address that already has a redirect is a 409.
POST
/
v2
/
library
/
redirects
Create Redirect
curl --request POST \
--url https://api.lightsage.com/v2/library/redirects \
--header 'Content-Type: application/json' \
--header 'X-Lightsage-Api-Key: <api-key>' \
--data '
{
"from_url": "<string>",
"to_url": "<string>",
"title": "<string>",
"live_on": "2023-12-25",
"task_id": "<string>"
}
'import requests
url = "https://api.lightsage.com/v2/library/redirects"
payload = {
"from_url": "<string>",
"to_url": "<string>",
"title": "<string>",
"live_on": "2023-12-25",
"task_id": "<string>"
}
headers = {
"X-Lightsage-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Lightsage-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
from_url: '<string>',
to_url: '<string>',
title: '<string>',
live_on: '2023-12-25',
task_id: '<string>'
})
};
fetch('https://api.lightsage.com/v2/library/redirects', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.lightsage.com/v2/library/redirects",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'from_url' => '<string>',
'to_url' => '<string>',
'title' => '<string>',
'live_on' => '2023-12-25',
'task_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Lightsage-Api-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.lightsage.com/v2/library/redirects"
payload := strings.NewReader("{\n \"from_url\": \"<string>\",\n \"to_url\": \"<string>\",\n \"title\": \"<string>\",\n \"live_on\": \"2023-12-25\",\n \"task_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Lightsage-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.lightsage.com/v2/library/redirects")
.header("X-Lightsage-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"from_url\": \"<string>\",\n \"to_url\": \"<string>\",\n \"title\": \"<string>\",\n \"live_on\": \"2023-12-25\",\n \"task_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lightsage.com/v2/library/redirects")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Lightsage-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"from_url\": \"<string>\",\n \"to_url\": \"<string>\",\n \"title\": \"<string>\",\n \"live_on\": \"2023-12-25\",\n \"task_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"title": "<string>",
"from_url": "<string>",
"to_url": "<string>",
"live_on": "2023-12-25",
"task_id": "<string>",
"added_at": "<string>",
"updated_at": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Body
application/json
Response
Successful Response