Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Endpoint: POST https://api.microsoft.ai/v3/search/web
Sample Request:
curl -X POST "https://api.microsoft.ai/v3/search/web" \
-H "host: api.microsoft.ai" \
-H "x-apikey: <Your API key>" \
-H "content-type: application/json" \
-d '{
"query": "latest trends in LLM RAG",
"maxResults": 10,
"language": "en",
"region": "US",
"maxLength": 3000,
"contentFormat": "passage"
}'
Parameters
| Parameter | Required | Type | Default | Description |
|---|---|---|---|---|
| query | Yes | string | - | A search query string. Maximum length is 1000 characters. Supports "site:" and "-site:" operators to include or exclude results from specific sites (e.g. "query site:example.com"). Use these operators only when necessary, as they inherently reduce result relevance. |
| maxResults | No | integer | 10 | Maximum number of results to return. Default is 10 and maximum value is 50. |
| language | No | string | "en" | A 2-letter ISO 639-1 language code for interface language in the search results. See Supported Languages for the full list. |
| region | No | string | "US" | A 2-letter country/region code for where the results should come from (e.g. "US", "JP", "GB", etc.). See Supported Regions for the full list. |
| location | No | string | - | Location information in format "lat:<float>;long:<float>", e.g. "lat:40.753250;long:-74.003807". If not specified, location in the query would be inferred. |
| freshness | No | string | - | The time range to filter results based on discovery date, not publication or last crawl date. Supports case-insensitive relative values "day", "week", "month", "year", or an ISO 8601 date interval: "YYYY-MM-DD/YYYY-MM-DD" or "YYYY-MM-DDTHH:mm:ssZ/YYYY-MM-DDTHH:mm:ssZ" for a date/datetime range. Datetimes must use whole seconds in UTC. Use .. to omit either boundary; when both boundaries are specified, use chronological order. Results discovered up to 12 hours before the start or after the end of the range can be returned; this is expected. Omit this parameter for no additional freshness filter. Not related to the freshness field in querySignals. |
| contentFormat | No | string | "passage" ("html" with full document access) | passage returns the parts of each result most relevant to the query (recommended for grounding). text, html and markdown return the full document and apply only to applications with full document access; see Passages and content formats. Set it on every request. Note: the web API does not return a snippet field. |
| maxLength | No | integer | 3000 (10000 with full document access) | Maximum characters in content per result, 1 to 500000. Without full document access, content is at most 3000 characters. See Defaults and limits. Set it on every request. |
| safeSearch | No | string | "strict" | Level of safe search filtering. Values: "off", "strict". Default is "strict". |
| includeSites | No | array of strings | - | Restricts results to these sites (domains with optional paths), with at most 250 entries. Keep the list short and relevant for best results. Paths support up to two segments; deeper paths are truncated, so example.com/a/b/c is treated as example.com/a/b. |
| excludeSites | No | array of strings | - | Omits results from these sites (domains with optional paths), with at most 250 entries and the same path rules as includeSites. If a site appears in both lists, it's excluded. |
| scopeName | No | string | - | One named scope from the collection assigned to the selected Web IQ AppID's billing account. Use 1-128 ASCII letters, digits, ., _, or -, without whitespace. Omitted or null means no named scope is requested. See Filter results with Scopes. |
| failOnMissingScope | No | boolean | true |
Controls fallback for scopeName; omitted or null means true. If the service reports that the scope could not be applied, true returns HTTP 400 (HandlerInvalidInput) for a confirmed missing scope, or HTTP 500 (ScopeFailedToApply) for other scope failures. false allows searching without the scope, with scopeApplied: false when that outcome is reported. A valid scope is applied with either value; zero matching results are not a scope failure. Has no effect without a named scope. See Named-scope errors. |
Note
freshness set to "day" reduces relevance. Use it only when you need results discovered in the last day.
Content formats
Set contentFormat = passage to get the parts of each result most relevant to the query, up to maxLength characters (3000 is a good starting point). It's the recommended format for grounding; see What is passage, and why use it? in the FAQ. Applications with full document access can also request the full document as text, html or markdown; for other applications, those formats return HTTP 403. See Passages and content formats.
SafeSearch
SafeSearch modes let you control how much sensitive web content the Web API filters out before results are returned. Sensitive content includes violence, self-harm, and other categories. Default value is strict.
| Value | Description | Recommended For |
|---|---|---|
strict |
Blocks content related to adult, racy, violence, hate, and self-harm topics. | Child-safe, education, consumer/conservative deployments. |
off |
Still blocks illegal content. For other potentially harmful content, shifts responsibility for final filtering to the user. | Research, analysis, opt-in enterprise, advanced 3P use cases. |
Note
If you use the site: query operator, the response may contain adult content regardless of the safeSearch value. Use site: only if you are aware of the content on the site and your scenario supports the possibility of adult content.
Request Headers
| Field | Type | Description |
|---|---|---|
| host | string | Host for Microsoft AI APIs: api.microsoft.ai. |
| x-apikey or Authorization | string | Your API key or Entra ID access token for authentication. |
| content-type | string | MIME type of the request body. Use application/json. |
Response
Web Response
| Field | Type | Description |
|---|---|---|
| webResults | array of webResult | List of web page results. |
| querySignals | querySignals | Query-level ranking signals for the search query. |
| scopeApplied | boolean (optional) | true means the requested scope was applied, not necessarily its latest definition. false means the scope was not applied; failOnMissingScope: false permits this unscoped response. Omitted when the service does not report an application outcome. Without scopeName, no named scope is requested; do not assume the field is present or always false. Describes the current request, not global propagation. |
| riskLevel | string | The safety risk level assessed for the query. Possible values: low, moderate, high, veryHigh. |
| instrumentationClickBase | string | Base URL for click ping requests. Append an instrumentationSuffix value from a result item to form the full ping URL. Only present for applications with the EnableInstrumentationPing profile flag. Note: User clicks can also be logged using URL redirection. When redirection is enabled, no action is required to log User clicks, and instrumentationClickBase will not be included in the response. See the Instrumentation guide for setup instructions. |
| instrumentationCitationBase | string | Base URL for LLM log ping requests. Append a DATA payload to form the full ping URL. Only present for applications with the EnableInstrumentationPing profile flag. |
| traceId | string | Trace ID for debugging. |
querySignals
| Field | Type | Description |
|---|---|---|
| freshness | boolean | Indicates whether fresh documents should be prioritized over other documents for this query. |
webResult
| Field | Type | Description |
|---|---|---|
| title | string | The title of the webpage. |
| url | string | The source URL of the webpage. For China users with URL redirection enabled, this field instead contains the same redirect URL as clickUrl. |
| domain | string | The destination host for the result. Returned only for China users with URL redirection enabled. |
| content | string | The detailed content (aka grounding) of the webpage. |
| crawledAt | string | The last crawled date of the webpage, follows ISO8601 format. |
| lastUpdatedAt | string | The last updated date of the webpage, follows ISO8601 format. |
| language | string | The language of the webpage, uses ISO 639-1 language code. |
| isAdult | boolean | Indicates whether the result includes adult content. |
| clickUrl | string | Redirect URL that proxies the click through Bing. Only present when click redirect is enabled. |
| instrumentationSuffix | string | Suffix to append to the instrumentation ping URL base for this result item. Used as the K value for both the instrumentation ping URL and the clickUrl redirect. Present when instrumentation ping is enabled. |
Note
Values of crawledAt and lastUpdatedAt fields are optional. That is, their coverage is not 100%. You may see empty values for these fields.
Error Codes
| Status Code | Error Category | Description | Common Causes |
|---|---|---|---|
| 200 | Success | The request succeeded. | - |
| 400 | Bad Request | Invalid request parameters. | Missing required fields, invalid parameter values, malformed JSON |
| 401 | Unauthorized | Authentication failed or missing. | Invalid API key, missing x-apikey header |
| 403 | Forbidden | Valid credentials but insufficient permissions. | API key lacks required permissions |
| 410 | Gone | HTTPS required. | Request made over HTTP instead of HTTPS |
| 415 | Unsupported Media Type | Content type not supported. | Missing or incorrect content-type header |
| 429 | Too Many Requests | Rate limit exceeded. | Too many requests in time window |
| 500 | Internal Server Error | Unexpected server error. | Temporary server issue |
| 503 | Service Unavailable | Service temporarily unavailable. | Maintenance or temporary outage |
| 504 | Gateway Timeout | Request timed out. | Upstream service timeout |
For detailed error handling guidance, see Error Handling.
See also: Videos Search | Browse | News Search | Images Search | MCP