Skip to main content
Mintlify
current

Search documentation

Type to search this documentation.

Get result contents

Retrieves content for Mintlify result IDs or result URLs returned by the search endpoint. A request can include up to 20 items across both fields.

Related topics

POST /v1/contents

cURL
curl --request POST \
  --url https://leaves.mintlify.com/api/universal-search/v1/contents \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "ids": [
    "nextjs:/docs/app/getting-started/caching-and-revalidating"
  ],
  "query": "revalidate cached data",
  "maxCharacters": 12000
}'
Python
import requests

url = "https://leaves.mintlify.com/api/universal-search/v1/contents"

payload = {
  "ids": [
    "nextjs:/docs/app/getting-started/caching-and-revalidating"
  ],
  "query": "revalidate cached data",
  "maxCharacters": 12000
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
JavaScript
const options = {method: "POST", headers: {"Authorization": "Bearer <token>", "Content-Type": "application/json"}, body: JSON.stringify({
  "ids": [
    "nextjs:/docs/app/getting-started/caching-and-revalidating"
  ],
  "query": "revalidate cached data",
  "maxCharacters": 12000
})};

fetch("https://leaves.mintlify.com/api/universal-search/v1/contents", options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
PHP
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://leaves.mintlify.com/api/universal-search/v1/contents",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\"ids\":[\"nextjs:/docs/app/getting-started/caching-and-revalidating\"],\"query\":\"revalidate cached data\",\"maxCharacters\":12000}",
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
Go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://leaves.mintlify.com/api/universal-search/v1/contents"

	payload := strings.NewReader("{\"ids\":[\"nextjs:/docs/app/getting-started/caching-and-revalidating\"],\"query\":\"revalidate cached data\",\"maxCharacters\":12000}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	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))

}
Java
HttpResponse<String> response = Unirest.post("https://leaves.mintlify.com/api/universal-search/v1/contents")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\"ids\":[\"nextjs:/docs/app/getting-started/caching-and-revalidating\"],\"query\":\"revalidate cached data\",\"maxCharacters\":12000}")
  .asString();
Ruby
require 'uri'
require 'net/http'

url = URI("https://leaves.mintlify.com/api/universal-search/v1/contents")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\"ids\":[\"nextjs:/docs/app/getting-started/caching-and-revalidating\"],\"query\":\"revalidate cached data\",\"maxCharacters\":12000}"

response = http.request(request)
puts response.read_body
200
{
  "requestId": "6bf694e4-76cb-4d31-a222-c94b2d9b198a",
  "results": [
    {
      "id": "nextjs:/docs/app/getting-started/caching-and-revalidating",
      "url": "https://nextjs.org/docs/app/getting-started/caching-and-revalidating",
      "title": "Caching and revalidating",
      "text": "# Caching and revalidating\n\nUse revalidation APIs to refresh cached data.",
      "truncated": false,
      "totalCharacters": 78,
      "score": 0,
      "source": "mintlify",
      "siteName": "nextjs",
      "breadcrumbs": [
        "App Router",
        "Getting started"
      ],
      "publishedDate": null
    }
  ],
  "statuses": [
    {
      "id": "nextjs:/docs/app/getting-started/caching-and-revalidating",
      "status": "success"
    }
  ]
}
400
{
  "error": "A request may reference at most 20 items across urls and ids"
}
401
{
  "error": "Unauthorized"
}
403
{
  "error": "IP address is not allowed for this API key"
}
429
{
  "error": "Rate limit exceeded. Please try again later"
}
500
{
  "error": "<string>"
}
Authorizationstringrequired

Mintlify Index API key with the mint_us_ prefix.

Typestring
urls?string[]

Result URLs to retrieve. Use this field for web results.

Typestring[]
ids?string[]

Mintlify result IDs to retrieve.

Typestring[]
maxCharacters?integer

Maximum number of content characters to return per result.

Required range: 1 <= x

Typeinteger
query?string

Query used to select the most relevant sections when content exceeds maxCharacters.

Required string length: 1+

Typestring

200 — Content retrieval completed. Check each status to determine whether its item succeeded.

requestIdstringrequired

Unique identifier for the request.

Typestring
resultsobject[]required

Successfully retrieved results.

Typeobject[]
Show child attributes
idstringrequired

Result identifier. Pass IDs from Mintlify results in the contents request's ids field. For web results, pass the result URL in urls.

Typestring
urlstringrequired

Canonical source URL.

Typestring
titlestringrequired

Source title.

Typestring
textstringrequired

Matched content when requested. Otherwise, an empty string.

Typestring
truncated?boolean

Whether the returned content is shorter than the available content.

Typeboolean
totalCharacters?integer

Number of available characters before truncation. Present when available.

Required range: 0 <= x

Typeinteger
scorenumberrequired

Relative relevance score. Contents responses use 0 because they retrieve selected items rather than rank results.

Typenumber
sourceenum<string>required

Retrieval source.

Available options: mintlify, web

Typeenum<string>
siteNamestringrequired

Documentation site or web hostname.

Typestring
breadcrumbsstring[]required

Documentation hierarchy for the result.

Typestring[]
publishedDatestring | nullrequired

Published date when the source provides one, otherwise null. search results normalize this to a full ISO 8601 timestamp. contents results retrieved by urls pass the source's original date string through unnormalized, which can be a full timestamp or a date-only string.

Typestring | null
statusesobject[]required

Retrieval status for each requested item.

Typeobject[]
Show child attributes
idstringrequired

Requested ID or URL.

Typestring
statusenum<string>required

Retrieval status.

Available options: success

Typeenum<string>
Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu