Build implementation context
Searches Mintlify Index and returns source-cited content assembled within a token budget. Use this endpoint when an application or agent needs ready-to-use context in one request.
curl --request POST \
--url https://leaves.mintlify.com/api/universal-search/v1/context \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "How should I configure caching in Next.js 16?",
"product": "Next.js",
"format": "txt",
"tokenBudget": 3000
}
'import requests
url = "https://leaves.mintlify.com/api/universal-search/v1/context"
payload = {
"query": "How should I configure caching in Next.js 16?",
"product": "Next.js",
"format": "txt",
"tokenBudget": 3000
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
query: 'How should I configure caching in Next.js 16?',
product: 'Next.js',
format: 'txt',
tokenBudget: 3000
})
};
fetch('https://leaves.mintlify.com/api/universal-search/v1/context', 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://leaves.mintlify.com/api/universal-search/v1/context",
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([
'query' => 'How should I configure caching in Next.js 16?',
'product' => 'Next.js',
'format' => 'txt',
'tokenBudget' => 3000
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://leaves.mintlify.com/api/universal-search/v1/context"
payload := strings.NewReader("{\n \"query\": \"How should I configure caching in Next.js 16?\",\n \"product\": \"Next.js\",\n \"format\": \"txt\",\n \"tokenBudget\": 3000\n}")
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))
}HttpResponse<String> response = Unirest.post("https://leaves.mintlify.com/api/universal-search/v1/context")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"How should I configure caching in Next.js 16?\",\n \"product\": \"Next.js\",\n \"format\": \"txt\",\n \"tokenBudget\": 3000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://leaves.mintlify.com/api/universal-search/v1/context")
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 = "{\n \"query\": \"How should I configure caching in Next.js 16?\",\n \"product\": \"Next.js\",\n \"format\": \"txt\",\n \"tokenBudget\": 3000\n}"
response = http.request(request)
puts response.read_body{
"requestId": "7f2ab8d1-3bea-4a29-bc51-c05a8d3a3e3c",
"query": "How should I configure caching in Next.js 16?",
"response": "### Caching and revalidating\n\nSource: https://nextjs.org/docs/app/getting-started/caching-and-revalidating\n\nUse the current caching APIs described in this guide.\n\n--------------------------------",
"resultsCount": 3,
"outputTokens": 1842
}{
"error": "Invalid request body"
}{
"error": "Unauthorized"
}{
"error": "IP address is not allowed for this API key"
}{
"error": "Rate limit exceeded. Please try again later"
}{
"error": "<string>"
}Authorizations
Mintlify Index API key with the mint_us_ prefix.
Body
Implementation question to research.
1Format of the response string. txt returns Markdown sections. json returns a serialized JSON object containing result items.
txt, json Product or company name to use as an additional retrieval hint.
1Domains to include in retrieval.
11Domains to exclude from retrieval.
11Maximum number of output tokens.
1 <= x <= 6000Response
Context assembled successfully.
Unique identifier for the request.
Original query from the request.
Assembled source content. The value is Markdown for txt requests and serialized JSON for json requests. The string can be empty when no content fits within the token budget.
Number of source snippets included in the response.
x >= 0Number of tokens in the assembled response.
x >= 0curl --request POST \
--url https://leaves.mintlify.com/api/universal-search/v1/context \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "How should I configure caching in Next.js 16?",
"product": "Next.js",
"format": "txt",
"tokenBudget": 3000
}
'import requests
url = "https://leaves.mintlify.com/api/universal-search/v1/context"
payload = {
"query": "How should I configure caching in Next.js 16?",
"product": "Next.js",
"format": "txt",
"tokenBudget": 3000
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
query: 'How should I configure caching in Next.js 16?',
product: 'Next.js',
format: 'txt',
tokenBudget: 3000
})
};
fetch('https://leaves.mintlify.com/api/universal-search/v1/context', 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://leaves.mintlify.com/api/universal-search/v1/context",
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([
'query' => 'How should I configure caching in Next.js 16?',
'product' => 'Next.js',
'format' => 'txt',
'tokenBudget' => 3000
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://leaves.mintlify.com/api/universal-search/v1/context"
payload := strings.NewReader("{\n \"query\": \"How should I configure caching in Next.js 16?\",\n \"product\": \"Next.js\",\n \"format\": \"txt\",\n \"tokenBudget\": 3000\n}")
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))
}HttpResponse<String> response = Unirest.post("https://leaves.mintlify.com/api/universal-search/v1/context")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"How should I configure caching in Next.js 16?\",\n \"product\": \"Next.js\",\n \"format\": \"txt\",\n \"tokenBudget\": 3000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://leaves.mintlify.com/api/universal-search/v1/context")
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 = "{\n \"query\": \"How should I configure caching in Next.js 16?\",\n \"product\": \"Next.js\",\n \"format\": \"txt\",\n \"tokenBudget\": 3000\n}"
response = http.request(request)
puts response.read_body{
"requestId": "7f2ab8d1-3bea-4a29-bc51-c05a8d3a3e3c",
"query": "How should I configure caching in Next.js 16?",
"response": "### Caching and revalidating\n\nSource: https://nextjs.org/docs/app/getting-started/caching-and-revalidating\n\nUse the current caching APIs described in this guide.\n\n--------------------------------",
"resultsCount": 3,
"outputTokens": 1842
}{
"error": "Invalid request body"
}{
"error": "Unauthorized"
}{
"error": "IP address is not allowed for this API key"
}{
"error": "Rate limit exceeded. Please try again later"
}{
"error": "<string>"
}