POST /find_redirect • Credits: 1 credit per call
Find Redirect follows a URL through every HTTP redirect and returns the final destination. Send a POST request with the link parameter. The response holds the final URL, the full redirect chain, the hop count, and the final HTTP status code. Each call costs 1 credit.
What does Find Redirect do?
A short link such as https://bit.ly/example hides its destination. A tracking link from an email tool or an ad platform hides the destination in the same way. Find Redirect sends the request itself, follows each Location header, and reports where the link ends. Find Redirect follows up to 20 hops and accepts the redirect status codes 301, 302, 303, 307, and 308. Find Redirect is a utility endpoint. It runs inside RichAPI and calls no external data provider. The only network traffic is the request to the target host and to every host in the redirect chain.
Which endpoint does Find Redirect use?
Method:
POSTURL:
https://api.richapi.ai/api/v1/find_redirectAuthentication:
x-api-keyheaderResponse: Synchronous JSON
Credits: 1 credit per call
How to send a Find Redirect request
Copy your API key from the RichAPI dashboard.
Set the
linkparameter to the short link or the tracking link.Send a
POSTrequest tohttps://api.richapi.ai/api/v1/find_redirect.Send the API key in the
x-api-keyheader.Read the
redirect_linkfield for the final destination.If
resolved_successfullyisfalse, treat the link as dead.
cURL
curl -X POST https://api.richapi.ai/api/v1/find_redirect
-H "x-api-key: YOUR_API_KEY"
-H "Content-Type: application/json"
-d '{
"link": "https://bit.ly/example"
}'
Python
import requests
response = requests.post(
"https://api.richapi.ai/api/v1/find_redirect",
headers={"x-api-key": "YOUR_API_KEY"},
json={"link": "https://bit.ly/example"},
timeout=60,
)
response.raise_for_status()
print(response.json())
Node.js
const response = await fetch("https://api.richapi.ai/api/v1/find_redirect", {
method: "POST",
headers: {
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
link: "https://bit.ly/example",
}),
});
const data = await response.json();
console.log(data);
Which parameters does Find Redirect accept?
Parameter | Type | Required | Default | Description |
| string | Yes | None | The URL to follow. The maximum length is 2048 characters. A missing value or an empty value returns a |
RichAPI adds no default value to the request body. An empty link value returns a 400 error.
How does Find Redirect follow a redirect chain?
Rule | What Find Redirect does |
Maximum hops | Follows 20 redirects. |
Redirect status codes | Follows |
Request method | Sends |
Timeout | Waits 10 seconds for each hop. |
Missing scheme | Adds |
Whitespace | Removes leading and trailing spaces before the request. |
Allowed schemes | Accepts |
Maximum length | Rejects a |
Relative | Joins a relative |
Missing | Stops at the current URL. |
Private hosts | Blocks |
Redirect loop | Stops after 20 hops and returns the chain that it collected. |
Find Redirect checks the host before the first request and again before every hop. If the first URL points at a private host, the response is a 400 error. If a later hop points at a private host, the response is a 200 response with resolved_successfully: false and final_status_code: 0.
What does Find Redirect return for real links?
The table below shows a real link value and the exact result for each field. Each row is one call.
|
|
|
|
|
| 2 |
| 200 |
|
| 2 |
| 200 |
|
| 1 |
| 200 |
|
| 1 |
| 200 |
|
| 1 |
| 200 |
|
| 0 |
| 200 |
|
| 0 |
| 200 |
|
| 0 |
| 404 |
|
A URL that sends no redirect returns redirect_count: 0 and is_redirected: false. In that case, redirect_link holds the same URL that you sent.
What does the Find Redirect response look like?
The block below is an example response for the request body {"link": "https://bit.ly/example"}. The short link passes through one HTTP hop before it reaches the final HTTPS page.
{
"original_link": "https://bit.ly/example",
"redirect_link": "https://vignettinglife.com/",
"redirect_chain": [
"https://bit.ly/example",
"http://vignettinglife.com/",
"https://vignettinglife.com/"
],
"redirect_count": 2,
"final_status_code": 200,
"is_redirected": true,
"resolved_successfully": true
}
Which fields does the Find Redirect response hold?
Field | Type | Description |
| string | The URL after normalization. Find Redirect trims the spaces and adds |
| string | The final destination URL. It is the last entry of |
| array of strings | Every URL in the chain, in order. The first entry is |
| integer | The number of redirects that Find Redirect followed. It is the length of |
| integer | The HTTP status code of the last response. If the host did not answer, or if a hop failed the private-host check, the value is |
| boolean | If |
| boolean | If the last status code is under 400, the value is |
How to resolve a tracking link before you store or scrape it
A list of scraped posts or emails holds short links and tracking links. Two different short links can point at the same page, so a count of unique links is wrong. Resolve each link first, then store the destination.
Read the raw link from each record in your list.
Send one Find Redirect request for each link.
Read the
resolved_successfullyfield from each response.Skip every record where
resolved_successfullyisfalse.Store the
redirect_linkvalue as the real destination.Send the
redirect_linkvalue to Web Scrape or to Clean Domain.
CAUTION: Do not send a short link to a scraping endpoint. The scraper reads the redirect page, and the call returns empty content and costs the full price.
How much does Find Redirect cost?
Find Redirect costs 1 credit per call. At $0.02 a credit, the rate on the 1,000 and 5,000 credit packs, one call costs $0.02. Larger packs cost less per credit. RichAPI charges the credit on a 200 response only. Every error response costs no credits.
Calls | Credits | Cost |
1 | 1 | $0.02 |
100 | 100 | $2.00 |
1,000 | 1,000 | $20.00 |
10,000 | 10,000 | $200.00 |
CAUTION: A response with resolved_successfully: false is still a 200 response. RichAPI charges 1 credit for it.
Which errors can Find Redirect return?
Status | Meaning | What to do |
| The request body is missing, the JSON is not valid, or the | Send a JSON object that holds one public |
| The API key is missing, wrong or revoked. | Send a valid key in the |
| The organization has no credits left, or the team reached its monthly spend limit. | Buy credits in the RichAPI dashboard. |
| This API key has no access to this endpoint ( | Call |
| The request used a method other than | Send the request again with the |
| The request rate is over the limit. | Wait, then send the request again. |
| The API failed. | Send the request again. If the failure repeats, contact support. |
Every error response holds an error field with a plain-language message.
Frequently asked questions
How many redirects does Find Redirect follow?
Find Redirect follows 20 redirects. The redirect_count field reports the number of hops that Find Redirect followed, and its maximum value is 20. A chain longer than 20 hops stops at hop 20.
Does Find Redirect return the full chain or only the final URL?
Find Redirect returns both. The redirect_chain field holds every URL in order, and the first entry is the URL that you sent. The redirect_link field holds the final destination on its own.
What happens on a redirect loop?
Find Redirect stops after 20 hops. The response holds redirect_count: 20, a redirect_chain of 21 URLs, and the status code of the last redirect in final_status_code, for example 302. A redirect status code is under 400, so resolved_successfully stays true. To detect the cap, compare redirect_count to 20.
What is the Find Redirect timeout?
Find Redirect waits 10 seconds for each hop. The timeout applies to one hop, and not to the whole chain. A host that does not answer returns a 200 response with final_status_code: 0 and resolved_successfully: false.
Can Find Redirect follow a link to an internal address?
No. Find Redirect blocks localhost, private IP addresses, reserved IP addresses, and link-local IP addresses. Find Redirect runs this check on the first URL and on every hop. An open redirect on a public host therefore cannot reach an internal address.
Does a dead short link still cost a credit?
Yes. A dead short link returns HTTP 200 with resolved_successfully: false, and RichAPI charges 1 credit. RichAPI charges no credit for a 400 error, for example an empty link value.
Is Find Redirect synchronous?
Yes. Find Redirect returns the result in the same response. The endpoint needs no second call, no polling, and no webhook.
Related articles
Extract URLs & Emails API
