# Test mode

> Build and test your integration or your agent with test keys (vp_test_…): realistic sample answers with the real checks and limits, nothing fetched, nothing charged.

Source: https://docs.virginproxy.com/test-mode/

A test key (`vp_test_…`) works like a live key, but every call gets a realistic sample answer instead of fetching the page. Your options are checked for real, the limits of your plan apply, errors look exactly as they will in production – and nothing is ever charged.

## Get a test key

Create one in the [dashboard](https://dash.virginproxy.com/keys) under **API keys** (choose “Test key”), or through the API with a live key:

**cURL**

```bash
curl https://api.virginproxy.com/v1/keys \
  -H "Authorization: Bearer $VP_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "local development",
    "mode": "test"
  }'
```

**Python**

```python
import os, requests

r = requests.post(
    "https://api.virginproxy.com/v1/keys",
    headers={"Authorization": "Bearer " + os.environ["VP_KEY"]},
    json={"name": "local development", "mode": "test"},
    timeout=30,
)
data = r.json()
if not r.ok:
    raise SystemExit(data["error"]["code"] + ": " + data["error"]["message"])
print(data["key"])
```

**Node.js**

```javascript
const res = await fetch("https://api.virginproxy.com/v1/keys", {
  method: "POST",
  headers: { Authorization: "Bearer " + process.env.VP_KEY, "Content-Type": "application/json" },
  body: JSON.stringify({ name: "local development", mode: "test" }),
  signal: AbortSignal.timeout(30_000),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error.code + ": " + data.error.message);
console.log(data.key);
```

**Python SDK**

```pysdk
from virginproxy import VirginProxy  # docs.virginproxy.com/sdk/virginproxy.py

vp = VirginProxy()  # reads VP_KEY
data = vp.call("POST", "/v1/keys", {"name": "local development", "mode": "test"})
print(data)
```

**Node SDK**

```nodesdk
import { VirginProxy } from "./virginproxy.mjs"; // docs.virginproxy.com/sdk/virginproxy.mjs

const vp = new VirginProxy(); // reads VP_KEY
const data = await vp.call("POST", "/v1/keys", { body: { name: "local development", mode: "test" } });
console.log(data);
```

**PHP**

```php
<?php
$ch = curl_init("https://api.virginproxy.com/v1/keys");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("VP_KEY"),
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode(["name" => "local development", "mode" => "test"], JSON_UNESCAPED_SLASHES),
]);
$data = json_decode(curl_exec($ch), true);
if (isset($data["error"])) {
    exit($data["error"]["code"] . ": " . $data["error"]["message"] . PHP_EOL);
}
echo $data["key"], PHP_EOL;
```

**Go**

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"os"
	"time"
)

func main() {
	payload := []byte(`{
  "name": "local development",
  "mode": "test"
}`)
	req, err := http.NewRequest("POST", "https://api.virginproxy.com/v1/keys", bytes.NewReader(payload))
	if err != nil {
		log.Fatal(err)
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("VP_KEY"))
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 30 * time.Second}
	res, err := client.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer res.Body.Close()

	var data map[string]any
	if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
		log.Fatal(err)
	}
	if res.StatusCode >= 300 {
		e := data["error"].(map[string]any)
		log.Fatalf("%v: %v", e["code"], e["message"])
	}
	fmt.Println(data["key"])
}
```

POST`/v1/keys`

Use it everywhere a live key goes: `Authorization: Bearer vp_test_…`. Switching to production is changing the key, nothing else.

## What you get

*POST /v1/requests with a test key (shortened):*

```json
{
  "id": "req_V3nQ8xLp2KdW7sTm0RcY",
  "status": 200,
  "final_url": "https://shop.example/products/1",
  "format": "markdown",
  "body": "# Trail Runner 2\n\nThis is a sample answer of the VirginProxy test mode. …",
  "extracted": { "price": 129 },
  "exit": { "ip": "203.0.113.10", "country": "DE" },
  "cost": { "credits": 0, "credits_used": 412, "credits_included": 25000 },
  "test": true,
  "…": "…"
}
```

- **Pages**: a sample shop page for the host you ask for, with a title, links, a price table, contact details and structured data. `format`, `main_content`, `parse` and the size limit work as usual; `extract` returns sample values of the type you asked for (`"Sample text"`, `129`, `42`, `true`, lists of two).
- **Screenshots and PDFs**: a small placeholder picture and a one-page PDF.
- **Map and crawl**: a sample site with a robots.txt, a sitemap and a handful of linked pages, so map finds addresses and a crawl grows and ends.
- **Jobs, batches and webhooks**: jobs and crawls made with a test key run in the background with sample answers, and their webhooks are really delivered – signed – to your URL.
- **MCP and the SDKs**: work with test keys unchanged.
- Every answer carries `"test": true` (or the header `X-VP-Test: true` for images, PDFs and raw answers) and `cost.credits` `0`.

## Simulate errors

Two query parameters in the target URL steer the sample answer. They are only read in test mode and never sent anywhere.

| Parameter | Effect |
| --- | --- |
| `vp_test_status=404` | The target answers with this HTTP status (100–599). |
| `vp_test_error=timeout` | The call fails with this error code, exactly as in production. Possible: `timeout`, `target_unreachable`, `connection_failed`, `tls_error`, `too_many_redirects`, `request_failed`, `busy`, `render_unavailable`, `rate_limited`, `concurrency_limited`, `credits_exhausted`, `maintenance`. |

*Test your retry logic:*

```bash
curl https://api.virginproxy.com/v1/requests \
  -H "Authorization: Bearer $VP_TEST_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://shop.example/?vp_test_error=busy"}'

# → 503 {"error": {"code": "busy", "retry_after_ms": 2000, …}} with Retry-After: 2
```

## What is the same, what is different

|  | Test key |
| --- | --- |
| Checks of your options | Real: an unknown option, a bad URL or a value out of range is refused as in production. |
| Plan rules | Real: what your plan does not include (for example a response larger than its size limit) is refused. |
| Rate and parallel limits | Your plan's, in a bucket of their own: testing never slows your live keys down. |
| Credits | Never charged; works with an empty balance. |
| Request log and usage | Not written: test calls do not appear in the request log or the statistics. The dashboard keeps them apart: its tab **Test calls** shows the last 200 of the past 24 hours (see [below](#test-calls)). |
| Keys and webhook settings | Not available with a test key (`key_management_not_allowed`). |

## See your test calls

In the [dashboard](https://dash.virginproxy.com/), the tab **Test calls** lists the last 200 calls made with your test keys within the past 24 hours, so you can check what your integration sent and what it got back. Older test calls are not kept, and none of them count towards your usage.

> **Note:** Sample answers show the shape of real answers, not the real content of a site. Before going live, run a few calls with a live key against the pages you need.
