> ## Documentation Index
> Fetch the complete documentation index at: https://namespace.so/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a client

> Create and configure a TypeScript SDK client for Namespace Devboxes.

Use `createDevboxClient()` to configure authentication, API transport, and Devbox connection defaults. The returned client provides access to Devboxes, blueprints, and images.

## `createDevboxClient()`

Create a client that provides access to Devboxes, blueprints, and images. The client loads credentials when it first makes an authenticated request.

### Example

```typescript {3} theme={null}
import { createDevboxClient } from "@namespacelabs/sdk/devbox";

const client = createDevboxClient();

/*  Work with the devbox client here */

// Close the connection at the end
client.close()
```

### API reference

```typescript theme={null}
createDevboxClient(options?: DevboxClientOptions): DevboxClient
```

#### Arguments and options

<ResponseField name="options" type="DevboxClientOptions">
  Options used to configure the client.

  <Expandable title="properties" defaultOpen>
    <ResponseField name="tokenSource" type="TokenSourceInput">
      Provides API tokens for Namespace requests and Devbox connections. Defaults to the Namespace workload token when available, then falls back to the local user token.
    </ResponseField>

    <ResponseField name="transport" type="Transport">
      A fully configured Connect transport for Devbox API requests. When provided, `baseUrl` is ignored and the SDK does not add RPC authentication. The `tokenSource` is still used to authenticate Devbox connections.
    </ResponseField>

    <ResponseField name="baseUrl" type="string">
      The Devbox API URL used by the default transport. Defaults to `NSC_DEVBOX_ENDPOINT` when set, or the Namespace `iad` regional endpoint. This does not select where Devboxes are created.
    </ResponseField>

    <ResponseField name="connectionTimeoutMs" type="number" default="90000">
      The default timeout, in milliseconds, for establishing a connection to a Devbox.
    </ResponseField>
  </Expandable>
</ResponseField>

#### Return value

`createDevboxClient()` returns a [`DevboxClient`](#devboxclient). In examples, this object is assigned to the `client` variable.

***

## `DevboxClient`

A `DevboxClient` provides APIs for working with Devboxes, blueprints, and images. It also manages the connections used to interact with Devboxes.

### Example

```typescript {4} theme={null}
import { createDevboxClient } from "@namespacelabs/sdk/devbox";

const client = createDevboxClient();
const devboxes = await client.devboxes.list();
```

### API reference

```typescript theme={null}
interface DevboxClient {
  devboxes: DevboxResource;
  blueprints: BlueprintResource;
  images: ImageResource;
  close(): void;
}
```

### Explore the APIs

Select an API to learn how to manage Devboxes, blueprints, or images with the client.

<Columns cols={3}>
  <Card title="client.devboxes" icon="container" href="/docs/reference/typescript-sdk/devboxes">
    Create, find, list, start, stop, and delete Devboxes.
  </Card>

  <Card title="client.blueprints" icon="layers" href="/docs/reference/typescript-sdk/blueprints">
    Create, find, list, update, and delete blueprints.
  </Card>

  <Card title="client.images" icon="hard-drive" href="/docs/reference/typescript-sdk/images">
    Register, find, list, inspect, optimize, and delete images.
  </Card>
</Columns>

***

## `client.close()`

Close connections cached by the client when your application no longer needs them. This does not delete Devboxes, blueprints, images, or other resources.

### Example

```typescript {5} theme={null}
import { createDevboxClient } from "@namespacelabs/sdk/devbox";

const client = createDevboxClient();

client.close();
```

### API reference

```typescript theme={null}
close(): void
```

#### Arguments and options

This method has no arguments or options.

#### Return value

Returns no value. Calling `close()` more than once has no effect.

## Related documentation

<Columns cols={2}>
  <Card title="Authenticate with Namespace" icon="key" href="/docs/reference/typescript-sdk/authentication">
    Configure credentials for local development and automated workloads.
  </Card>

  <Card title="Create and manage Devboxes" icon="container" href="/docs/reference/typescript-sdk/devboxes">
    Use the client's Devbox resource and manage Devbox lifecycles.
  </Card>
</Columns>
