> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.meshapi.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.meshapi.ai/_mcp/server.

# Web Search

POST https://api.meshapi.ai/v1/web/search
Content-Type: application/json

Reference: https://developers.meshapi.ai/api-reference/mesh-api/web-search

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: openapi
  version: 1.0.0
paths:
  /v1/web/search:
    post:
      operationId: web-search
      summary: Web Search
      tags:
        - ''
      parameters:
        - name: Authorization
          in: header
          description: Bearer authentication
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebSearchResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebSearchRequest'
servers:
  - url: https://api.meshapi.ai
    description: Production Server
components:
  schemas:
    WebSearchRequestProvider:
      type: string
      enum:
        - native
        - tavily
      description: Pin a specific engine. Omit to use native-first with Tavily fallback.
      title: WebSearchRequestProvider
    WebSearchRequestSearchDepth:
      type: string
      enum:
        - basic
        - advanced
      default: basic
      description: Tavily search depth; ignored by the native engine.
      title: WebSearchRequestSearchDepth
    WebSearchRequest:
      type: object
      properties:
        query:
          type: string
          description: The search query.
        model:
          type:
            - string
            - 'null'
          description: Native engine model id. Defaults to the server's configured model.
        provider:
          oneOf:
            - $ref: '#/components/schemas/WebSearchRequestProvider'
            - type: 'null'
          description: >-
            Pin a specific engine. Omit to use native-first with Tavily
            fallback.
        max_results:
          type: integer
          default: 5
          description: Maximum results to return.
        search_depth:
          $ref: '#/components/schemas/WebSearchRequestSearchDepth'
          description: Tavily search depth; ignored by the native engine.
        include_domains:
          type:
            - array
            - 'null'
          items:
            type: string
          description: Restrict results to these domains.
        exclude_domains:
          type:
            - array
            - 'null'
          items:
            type: string
          description: Drop results from these domains.
        include_answer:
          type: boolean
          default: false
          description: Ask the engine for a synthesized answer alongside results.
      required:
        - query
      title: WebSearchRequest
    WebSearchResultItem:
      type: object
      properties:
        title:
          type: string
        url:
          type: string
        content:
          type: string
          default: ''
        score:
          type:
            - number
            - 'null'
          format: double
        published_date:
          type:
            - string
            - 'null'
      required:
        - title
        - url
      title: WebSearchResultItem
    WebSearchResponseProvider:
      type: string
      enum:
        - native
        - tavily
      title: WebSearchResponseProvider
    WebSearchResponse:
      type: object
      properties:
        query:
          type: string
        answer:
          type:
            - string
            - 'null'
        results:
          type: array
          items:
            $ref: '#/components/schemas/WebSearchResultItem'
        provider:
          $ref: '#/components/schemas/WebSearchResponseProvider'
        request_id:
          type: string
          default: ''
      required:
        - query
        - provider
      title: WebSearchResponse
    ValidationErrorLocItems:
      oneOf:
        - type: string
        - type: integer
      title: ValidationErrorLocItems
    ValidationErrorCtx:
      type: object
      properties: {}
      title: ValidationErrorCtx
    ValidationError:
      type: object
      properties:
        loc:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorLocItems'
        msg:
          type: string
        type:
          type: string
        input:
          description: Any type
        ctx:
          $ref: '#/components/schemas/ValidationErrorCtx'
      required:
        - loc
        - msg
        - type
      title: ValidationError
    HTTPValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
      title: HTTPValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

```

## Examples

### Example response



**Request**

```json
undefined
```

**Response**

```json
{
  "query": "latest James Webb telescope discoveries",
  "provider": "native",
  "answer": "Recent JWST observations include early-galaxy candidates and new exoplanet atmosphere measurements.",
  "results": [
    {
      "title": "JWST spots an early galaxy candidate",
      "url": "https://example.com/jwst",
      "content": "Astronomers using JWST reported a distant galaxy candidate...",
      "score": 0.93
    }
  ],
  "request_id": "req_01ARZ3NDEKTSV4RRFFQ69G5FAV"
}
```

**SDK Code**

```python Example response
import requests

url = "https://api.meshapi.ai/v1/web/search"

headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Example response
const url = 'https://api.meshapi.ai/v1/web/search';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: undefined
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Example response
package main

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

func main() {

	url := "https://api.meshapi.ai/v1/web/search"

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

	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(res)
	fmt.Println(string(body))

}
```

```ruby Example response
require 'uri'
require 'net/http'

url = URI("https://api.meshapi.ai/v1/web/search")

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'

response = http.request(request)
puts response.read_body
```

```java Example response
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.meshapi.ai/v1/web/search")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .asString();
```

```php Example response
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.meshapi.ai/v1/web/search', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Example response
using RestSharp;

var client = new RestClient("https://api.meshapi.ai/v1/web/search");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
```

```swift Example response
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.meshapi.ai/v1/web/search")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Example request



**Request**

```json
{
  "query": "latest James Webb telescope discoveries",
  "model": "perplexity/sonar",
  "max_results": 5,
  "include_answer": true
}
```

**Response**

```json
{
  "query": "latest James Webb telescope discoveries",
  "provider": "native",
  "answer": "Recent JWST observations include early-galaxy candidates and new exoplanet atmosphere measurements.",
  "results": [
    {
      "title": "JWST spots an early galaxy candidate",
      "url": "https://example.com/jwst",
      "content": "Astronomers using JWST reported a distant galaxy candidate...",
      "score": 0.93
    }
  ],
  "request_id": "req_01ARZ3NDEKTSV4RRFFQ69G5FAV"
}
```

**SDK Code**

```python Example request
import requests

url = "https://api.meshapi.ai/v1/web/search"

payload = {
    "query": "latest James Webb telescope discoveries",
    "model": "perplexity/sonar",
    "max_results": 5,
    "include_answer": True
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Example request
const url = 'https://api.meshapi.ai/v1/web/search';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"query":"latest James Webb telescope discoveries","model":"perplexity/sonar","max_results":5,"include_answer":true}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Example request
package main

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

func main() {

	url := "https://api.meshapi.ai/v1/web/search"

	payload := strings.NewReader("{\n  \"query\": \"latest James Webb telescope discoveries\",\n  \"model\": \"perplexity/sonar\",\n  \"max_results\": 5,\n  \"include_answer\": true\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(res)
	fmt.Println(string(body))

}
```

```ruby Example request
require 'uri'
require 'net/http'

url = URI("https://api.meshapi.ai/v1/web/search")

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\": \"latest James Webb telescope discoveries\",\n  \"model\": \"perplexity/sonar\",\n  \"max_results\": 5,\n  \"include_answer\": true\n}"

response = http.request(request)
puts response.read_body
```

```java Example request
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.meshapi.ai/v1/web/search")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"query\": \"latest James Webb telescope discoveries\",\n  \"model\": \"perplexity/sonar\",\n  \"max_results\": 5,\n  \"include_answer\": true\n}")
  .asString();
```

```php Example request
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.meshapi.ai/v1/web/search', [
  'body' => '{
  "query": "latest James Webb telescope discoveries",
  "model": "perplexity/sonar",
  "max_results": 5,
  "include_answer": true
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Example request
using RestSharp;

var client = new RestClient("https://api.meshapi.ai/v1/web/search");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"query\": \"latest James Webb telescope discoveries\",\n  \"model\": \"perplexity/sonar\",\n  \"max_results\": 5,\n  \"include_answer\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Example request
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "query": "latest James Webb telescope discoveries",
  "model": "perplexity/sonar",
  "max_results": 5,
  "include_answer": true
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.meshapi.ai/v1/web/search")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```