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

# Send a Web Unlocker / SERP request

POST https://api.nativeport.ai/brightdata
Content-Type: application/json

Relays to `https://api.brightdata.com/request`; `Authorization` is rewritten to Bright
Data's secret key. `POST` only, every control in the JSON body. Leave `zone` out and the
gateway fills it from its configured zone. Request `format: "raw"` and the target site's
bytes come back exactly as the site sent them.


Reference: https://docs.nativeport.ai/api-reference/api-reference/bright-data/brightdata-proxy

## Authentication

- `Authorization` header (bearer token, required) — Your per-client bearer token — the API key the gateway issued to you. Present it in `Authorization: Bearer <token>` form. A token that is missing, unknown, or revoked draws a `401`. Before the call is sent upstream the token is removed (stripped, or swapped for the upstream's own credential); it never makes it past the gateway.

## Servers

- `https://api.nativeport.ai` (NativePort production, default)
- `http://localhost:8787` (Local development (wrangler dev))

## Request

### Body (application/json)

This endpoint expects a map from string to any.

- `map from string to any`

## Response

### 200

The upstream's answer, relayed as-is. Typically the scraped page as HTML, raw bytes, or JSON under a structured/parsed mode. The upstream defines the exact shape.

- `map from string to any`

## Errors

### 401 Unauthorized Error

The bearer token was missing, unknown, or revoked. The reply body is the JSON `{ "error": "Unauthorized." }`.

- `error` (string, required) — Explanatory message meant for humans.

### 404 Not Found Error

No route matched the path, or the matched route disallows that method (an unlisted `/serper/<endpoint>`, for instance). The body lists every mounted route, verbatim as the gateway sends it. A path on one of the four model-inference routes also `404`s this way when the specific endpoint or model isn't on that provider's allowlist; an unsupported model addressed through `/inference` gets that endpoint's own `400` instead (see the Inference tag).

- `error` (string, required) — Explanatory message meant for humans.

## Examples

**Request**

```json
{
  "format": "raw",
  "url": "https://example.com"
}
```

**Response**

```json
{}
```

**SDK Code**

```python Web Unlocker request
import requests

url = "https://api.nativeport.ai/brightdata"

payload = {
    "format": "raw",
    "url": "https://example.com"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Web Unlocker request
const url = 'https://api.nativeport.ai/brightdata';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"format":"raw","url":"https://example.com"}'
};

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

```go Web Unlocker request
package main

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

func main() {

	url := "https://api.nativeport.ai/brightdata"

	payload := strings.NewReader("{\n  \"format\": \"raw\",\n  \"url\": \"https://example.com\"\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 Web Unlocker request
require 'uri'
require 'net/http'

url = URI("https://api.nativeport.ai/brightdata")

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  \"format\": \"raw\",\n  \"url\": \"https://example.com\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.nativeport.ai/brightdata")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"format\": \"raw\",\n  \"url\": \"https://example.com\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.nativeport.ai/brightdata', [
  'body' => '{
  "format": "raw",
  "url": "https://example.com"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Web Unlocker request
using RestSharp;

var client = new RestClient("https://api.nativeport.ai/brightdata");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"format\": \"raw\",\n  \"url\": \"https://example.com\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Web Unlocker request
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "format": "raw",
  "url": "https://example.com"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.nativeport.ai/brightdata")! 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()
```