# How to Configure V3HttpTransport with Endpoint, API Key, Service ID, Timeout, and TLS Validation

> Learn to configure V3HttpTransport with endpoint, apiKey, serviceId, timeout, and TLS validation in TencentDB Agent Memory. Follow our guide for a seamless setup.

- Repository: [Tencent Cloud/TencentDB-Agent-Memory](https://github.com/TencentCloud/TencentDB-Agent-Memory)
- Tags: how-to-guide
- Published: 2026-08-31

---

**Pass an `HttpTransportOptions` object to the `V3HttpTransport` constructor with `endpoint`, `apiKey`, `serviceId`, and optional `timeout` and `rejectUnauthorized` fields.**

`V3HttpTransport` serves as the low-level HTTP client powering all v3 SDK clients—including `SkillClient` and `MemoryClient`—in the TencentDB Agent Memory TypeScript SDK. Configuring it correctly ensures secure, authenticated communication with the TencentDB Agent Memory gateway.

---

## Understanding the HttpTransportOptions Interface

The `V3HttpTransport` constructor accepts a single configuration object. According to [`sdk/memory-core/typescript/src/v3/http.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/sdk/memory-core/typescript/src/v3/http.ts) (lines 15-41), five options control transport behavior:

| Option | Required | Default | Description |
|--------|----------|---------|-------------|
| `endpoint` | Yes | — | Base URL of the gateway (validated via `new URL()`) |
| `apiKey` | Yes | — | Bearer token for `Authorization` header |
| `serviceId` | Yes | — | Memory instance ID sent as `x-tdai-service-id` |
| `timeout` | No | 30000 | Request timeout in milliseconds |
| `rejectUnauthorized` | No | false | Whether to validate TLS certificates |

The source enforces strict validation: `endpoint` must start with `http:` or `https:`, `apiKey` and `serviceId` must be non-empty strings, and `timeout` must be a finite positive number (lines 15-29).

---

## Required Configuration: Endpoint, API Key, and Service ID

These three fields are mandatory. The constructor builds internal headers from them:

```ts
this.headers = {
  Authorization: `Bearer ${opts.apiKey}`,
  "x-tdai-service-id": opts.serviceId,
  "Content-Type": "application/json",
};

```

Code location: [`sdk/memory-core/typescript/src/v3/http.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/sdk/memory-core/typescript/src/v3/http.ts), lines 31-35.

**Example instantiation:**

```typescript
import { V3HttpTransport } from "@tencentdb/memory-sdk/v3";

const transport = new V3HttpTransport({
  endpoint: "https://memory.tencentyun.com",
  apiKey: "sk-xxxxxxxxxxxxxxxxxxxx",
  serviceId: "mem-12345"
});

```

---

## Optional Configuration: Timeout and TLS Validation

### Setting a Custom Timeout

The `timeout` parameter aborts requests exceeding the specified duration. Pass a positive number in milliseconds:

```typescript
const transport = new V3HttpTransport({
  endpoint: "https://memory.tencentyun.com",
  apiKey: "sk-xxxxxxxxxxxxxxxxxxxx",
  serviceId: "mem-12345",
  timeout: 60000  // 60 seconds
});

```

Omitting `timeout` defaults to **30,000 ms** (line 26: `this.timeout = opts.timeout ?? 30_000`).

### Controlling TLS Certificate Validation with rejectUnauthorized

The `rejectUnauthorized` boolean determines how the transport handles TLS certificates:

- **`false`** (default): Creates an `undici` Agent with `rejectUnauthorized: false`, allowing self-signed certificates—useful for development environments (lines 39-41).
- **`true`**: Uses default Node.js TLS behavior, strictly validating certificates against trusted CAs.

```typescript
// Production: strict validation
const strictTransport = new V3HttpTransport({
  endpoint: "https://memory.tencentyun.com",
  apiKey: "sk-xxxxxxxxxxxxxxxxxxxx",
  serviceId: "mem-12345",
  rejectUnauthorized: true
});

// Development: allow self-signed certificates
const devTransport = new V3HttpTransport({
  endpoint: "https://localhost:8443",
  apiKey: "sk-test-key",
  serviceId: "mem-dev",
  timeout: 10000,
  rejectUnauthorized: false
});

```

Implementation detail (line 40): `new Agent({ connect: { rejectUnauthorized: false } })`.

---

## Complete Configuration Examples

### Basic Production Setup

```typescript
import { V3HttpTransport } from "@tencentdb/memory-sdk/v3";

const transport = new V3HttpTransport({
  endpoint: "https://memory.tencentyun.com",
  apiKey: process.env.TENCENTDB_API_KEY!,
  serviceId: "mem-prod-001",
  timeout: 45000,
  rejectUnauthorized: true
});

```

### Development with Self-Signed Certificates

```typescript
const transport = new V3HttpTransport({
  endpoint: "https://10.0.0.5:8443",
  apiKey: "sk-local-test",
  serviceId: "mem-local",
  timeout: 10000,
  rejectUnauthorized: false  // default, explicit for clarity
});

```

### Integration with SkillClient

`SkillClient` internally constructs `V3HttpTransport` from the same options object. Pass configuration directly:

```typescript
import { SkillClient } from "@tencentdb/memory-sdk/v3";

const client = new SkillClient({
  endpoint: "https://memory.tencentyun.com",
  apiKey: "sk-xxxxxxxxxxxxxxxxxxxx",
  serviceId: "mem-12345",
  timeout: 60000,
  rejectUnauthorized: true,
  // Client-specific defaults
  teamId: "team-engineering",
  agentId: "agent-copilot"
});

// All requests use the configured transport
await client.create({
  name: "code-review-skill",
  content: "---\nname: code-review-skill\n..."
});

```

Source reference: [`sdk/memory-core/typescript/src/v3/skill-client.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/sdk/memory-core/typescript/src/v3/skill-client.ts) demonstrates this pattern.

---

## Key Implementation Files

| File | Purpose |
|------|---------|
| [`sdk/memory-core/typescript/src/v3/http.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/sdk/memory-core/typescript/src/v3/http.ts) | `V3HttpTransport` class, validation logic, and request implementation |
| [`sdk/memory-core/typescript/src/v3/skill-client.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/sdk/memory-core/typescript/src/v3/skill-client.ts) | High-level client that consumes `V3HttpTransport` |
| [`sdk/memory-core/typescript/src/http.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/sdk/memory-core/typescript/src/http.ts) | Legacy non-v3 transport (comparison reference) |

---

## Summary

- **`V3HttpTransport`** requires `endpoint`, `apiKey`, and `serviceId`—all validated on construction.
- **`timeout`** defaults to 30 seconds; specify in milliseconds for custom limits.
- **`rejectUnauthorized`** defaults to `false` (permissive); set to `true` for production TLS validation.
- Configuration propagates to **all v3 SDK clients** (`SkillClient`, `MemoryClient`) through the same `HttpTransportOptions` interface.
- Internal validation occurs in [`sdk/memory-core/typescript/src/v3/http.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/sdk/memory-core/typescript/src/v3/http.ts), lines 15-41.

---

## Frequently Asked Questions

### What happens if I omit the timeout option?

The transport defaults to **30,000 milliseconds** (30 seconds). The constructor applies `opts.timeout ?? 30_000` as shown in line 26 of [`http.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/http.ts).

### Why does rejectUnauthorized default to false?

The default accommodates development environments and on-premise deployments using self-signed certificates. For production workloads handling sensitive data, explicitly set `rejectUnauthorized: true` to enforce strict certificate chain validation.

### Can I change configuration after creating V3HttpTransport?

No. `V3HttpTransport` creates an immutable internal state during construction. To modify settings, instantiate a new transport with updated options. Higher-level clients like `SkillClient` follow the same pattern.

### How does V3HttpTransport differ from the legacy HttpTransport?

`V3HttpTransport` (in [`src/v3/http.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/src/v3/http.ts)) uses the modern `undici` HTTP client and implements v3 API authentication headers. The legacy `HttpTransport` (in [`src/http.ts`](https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/main/src/http.ts)) targets earlier API versions with different authentication schemes. Use `V3HttpTransport` for all new v3 SDK development.