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.
Related topics
POST /v1/context
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_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"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("{\"query\":\"How should I configure caching in Next.js 16?\",\"product\":\"Next.js\",\"format\":\"txt\",\"tokenBudget\":3000}")
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("{\"query\":\"How should I configure caching in Next.js 16?\",\"product\":\"Next.js\",\"format\":\"txt\",\"tokenBudget\":3000}")
.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 = "{\"query\":\"How should I configure caching in Next.js 16?\",\"product\":\"Next.js\",\"format\":\"txt\",\"tokenBudget\":3000}"
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\nSource: https://nextjs.org/docs/app/getting-started/caching-and-revalidating\nUse the current caching APIs described in this guide.\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
Section titled “Authorizations”AuthorizationstringrequiredMintlify Index API key with the mint_us_ prefix.
querystringrequiredImplementation question to research.
Required string length: 1+
product?stringProduct or company name to use as an additional retrieval hint.
Required string length: 1+
formatenum<string>requiredFormat of the response string. txt returns Markdown sections. json returns a serialized JSON object containing result items.
Available options: txt, json
includeDomains?string[]Domains to include in retrieval.
excludeDomains?string[]Domains to exclude from retrieval.
tokenBudget?integerMaximum number of output tokens.
Required range: 1 <= x <= 6000
Response
Section titled “Response”200 — Context assembled successfully.
requestIdstringrequiredUnique identifier for the request.
querystringrequiredOriginal query from the request.
responsestringrequiredAssembled 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.
resultsCountintegerrequiredNumber of source snippets included in the response.
Required range: 0 <= x
outputTokensintegerrequiredNumber of tokens in the assembled response.
Required range: 0 <= x