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

# Scan records

POST http://127.0.0.1:8090/v1/records/scan
Content-Type: application/json

Current TraceDB v1 product route. This OpenAPI artifact is generated from the checked-in route manifest.

Reference: https://docs.trace-db.com/api-reference/tracedb/records/post-records-scan

## Authentication

- `Authorization` header (bearer token, required) — Required by gateway-managed routes; direct local engine development can use any token.

## Servers

- `http://127.0.0.1:8090` (Local tracedb-server, default)
- `https://api.trace-db.com` (Hosted TraceDB API)

## Request

### Body (application/json)

This endpoint expects a RecordScanRequest.

- `cursor` (string, optional, nullable) — Opaque cursor returned by the previous scan page.
- `limit` (integer, optional)
- `table` (string, optional)
- `tenant_id` (string, optional)

## Response

### 200

Successful TraceDB response.

- `next_cursor` (string, optional, nullable)
- `records` (list of RecordOutput, optional)
- `returned_count` (integer, optional)

## Errors

### 400 Bad Request Error

Bad request or validation failure.

- `code` (string, optional) — Stable machine-readable error code when available; existing clients can continue to read error.
- `error` (string, optional)

### 401 Unauthorized Error

Unauthorized gateway request.

- `code` (string, optional) — Stable machine-readable error code when available; existing clients can continue to read error.
- `error` (string, optional)

### 404 Not Found Error

Route not found.

- `code` (string, optional) — Stable machine-readable error code when available; existing clients can continue to read error.
- `error` (string, optional)

### 429 Too Many Requests Error

Gateway rate limit exceeded.

- `code` (string, optional) — Stable machine-readable error code when available; existing clients can continue to read error.
- `error` (string, optional)

### 500 Internal Server Error

Engine or gateway failure.

- `code` (string, optional) — Stable machine-readable error code when available; existing clients can continue to read error.
- `error` (string, optional)

### 502 Bad Gateway Error

Gateway upstream failure.

- `code` (string, optional) — Stable machine-readable error code when available; existing clients can continue to read error.
- `error` (string, optional)

### 503 Service Unavailable Error

Service unavailable.

- `code` (string, optional) — Stable machine-readable error code when available; existing clients can continue to read error.
- `error` (string, optional)

## Types

### RecordOutput

TraceDB visible record output.

- `fields` (map from string to any, optional) — Record field map.
- `id` (string, optional)
- `table` (string, optional)
- `tenant_id` (string, optional)
- `version_id` (integer, optional)

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "next_cursor": "eyJ0YWJsZSI6ICJ1c2VycyIsICJvZmZzZXQiOiAxMH0=",
  "records": [
    {
      "fields": {},
      "id": "rec_7f8a9b3c2d1e4f5a",
      "table": "users",
      "tenant_id": "tenant_12345",
      "version_id": 3
    }
  ],
  "returned_count": 1
}
```

**SDK Code**

```python
import requests

url = "http://127.0.0.1:8090/v1/records/scan"

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

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

print(response.json())
```

```javascript
const url = 'http://127.0.0.1:8090/v1/records/scan';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

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

```go
package main

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

func main() {

	url := "http://127.0.0.1:8090/v1/records/scan"

	payload := strings.NewReader("{}")

	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
require 'uri'
require 'net/http'

url = URI("http://127.0.0.1:8090/v1/records/scan")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

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

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

HttpResponse<String> response = Unirest.post("http://127.0.0.1:8090/v1/records/scan")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://127.0.0.1:8090/v1/records/scan', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("http://127.0.0.1:8090/v1/records/scan");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

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

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

let request = NSMutableURLRequest(url: NSURL(string: "http://127.0.0.1:8090/v1/records/scan")! 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()
```