---
title: NameRecord
description: "One named VM: everything Sandbox.adopt needs, under a name."
---

One named VM: everything `Sandbox.adopt` needs, under a name.

## Constructors

### Constructor

```ts
new NameRecord(
   name: string, 
   microvmId: string, 
   endpoint: string, 
   agentToken: string, 
   region: Region
): NameRecord;
```

A record for a VM this process can already address. Refuses an illegal name or an
empty id, endpoint, or token.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `name` | `string` |
| `microvmId` | `string` |
| `endpoint` | `string` |
| `agentToken` | `string` |
| `region` | [`Region`](/microvms-agentd/reference/typescript/classes/region/) |

#### Returns

`NameRecord`

## Accessors

### at

#### Get Signature

```ts
get at(): number;
```

Seconds since the epoch when the name was registered.

##### Returns

`number`

***

### egressPosture

#### Get Signature

```ts
get egressPosture(): string | null;
```

##### Returns

`string` | `null`

***

### endpoint

#### Get Signature

```ts
get endpoint(): string;
```

##### Returns

`string`

***

### microvmId

#### Get Signature

```ts
get microvmId(): string;
```

##### Returns

`string`

***

### name

#### Get Signature

```ts
get name(): string;
```

##### Returns

`string`

***

### region

#### Get Signature

```ts
get region(): string;
```

##### Returns

`string`

## Methods

### agentToken()

```ts
agentToken(): string;
```

The VM's bearer credential. A method rather than a getter, so it is never read by
accident; store it only privately.

#### Returns

`string`

***

### toObject()

```ts
toObject(): NameRecordObject;
```

The record as a plain object, **agent token included** — the form to store privately
and read back with `fromObject`.

#### Returns

[`NameRecordObject`](/microvms-agentd/reference/typescript/interfaces/namerecordobject/)

***

### toString()

```ts
toString(): string;
```

The record without its secrets.

#### Returns

`string`

***

### tunnelIdentity()

```ts
tunnelIdentity(): TunnelIdentity | null;
```

The VM's tunnel identity, when it was launched with `identity: true`; `null` otherwise.

Throws when the record carries one half of the pair, or a half that doesn't decode: the
record claims a verifiable VM, and reading it as unverifiable would hide that it's
broken. A method, like `agentToken()`, because it holds the host's secret half.

#### Returns

[`TunnelIdentity`](/microvms-agentd/reference/typescript/classes/tunnelidentity/) | `null`

***

### forSandbox()

```ts
static forSandbox(name: string, sandbox: Sandbox): Promise<NameRecord>;
```

A record naming the VM `sandbox` addresses — launched or adopted.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `name` | `string` |
| `sandbox` | [`Sandbox`](/microvms-agentd/reference/typescript/classes/sandbox/) |

#### Returns

`Promise`\<`NameRecord`>

***

### fromObject()

```ts
static fromObject(object: NameRecordObject): NameRecord;
```

A record from `toObject()` output (or a CLI registry file's JSON), checked.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `object` | [`NameRecordObject`](/microvms-agentd/reference/typescript/interfaces/namerecordobject/) |

#### Returns

`NameRecord`

## Provenance

This page is generated from `bindings/microvms-js/index.d.ts` by TypeDoc 0.28.20 and typedoc-plugin-markdown 4.13.1, run from `site/scripts/gen-reference.mjs` on every `pnpm run sync`, so an edit made here is overwritten by the next run.

To change the page, change the doc comment in the binding's Rust source, then regenerate the declarations with `mise run dts`. `mise run dts:check` fails when the committed file no longer matches the source.