# FirmhouseClient

Client for accessing Firmhouse GraphQL api

## Example

```typescript
import { FirmhouseClient, Access } from '@firmhouse/sdk';
const client = new FirmhouseClient({
 apiToken,
 accessType: Access.write
});

const cart = await client.carts.getOrCreate();
const products = await client.products.fetchAll();
const invoices = await client.invoices.fetchAll();
```

## Type parameters

• **TAccess** extends [`Access`](/sdks/firmhouse-sdk/reference/enumerations/access.md) = [`storefront`](https://github.com/firmhouse/developer-docs/blob/main/docs/sdks/firmhouse-sdk/reference/enumerations/Access.md#storefront)

Access type. (Will be inferred from the config)

## Methods

### rawRequest()

```ts
rawRequest(graphQLQuery, variables?): Promise<unknown>
```

Sends an authenticated raw request to API. This can be used for custom field selections or bulk queries/mutations.

#### Parameters

• **graphQLQuery**: `string`

The GraphQL query

• **variables?**: `Record`<`string`, `unknown`>

Variables to use in query

#### Returns

`Promise`<`unknown`>

The response from the API

#### Throws

* [NotFoundError](/sdks/firmhouse-sdk/reference/errors/not-found.md) - When there is an entity not found error in the response
* [ValidationError](/sdks/firmhouse-sdk/reference/errors/validation.md) - When there are invalid fields
* [ServerError](/sdks/firmhouse-sdk/reference/errors/server.md) - When the request fails

## Resources

### Available with Storefront Access

#### carts

```ts
get carts(): Carts
```

Cart methods

**Returns**

[`Carts`](/sdks/firmhouse-sdk/reference/resources/carts.md)

***

#### plans

```ts
get plans(): Plans
```

Plan methods

**Example**

```typescript
const plans = await client.plans.fetchAll();
```

**Returns**

[`Plans`](/sdks/firmhouse-sdk/reference/resources/plans.md)

***

#### products

```ts
get products(): Products
```

Product methods

**Example**

```typescript
const products = await client.products.fetchAll();
```

**Returns**

[`Products`](/sdks/firmhouse-sdk/reference/resources/products.md)

***

#### selfServiceCenterToken

```ts
get selfServiceCenterToken(): SelfServiceCenterToken
```

SelfServiceCenterToken methods

**Returns**

[`SelfServiceCenterToken`](/sdks/firmhouse-sdk/reference/resources/self-service-center-token.md)

### Only Available with Write Access

#### invoices

```ts
get invoices(): TAccess extends write ? Invoices : never
```

Invoice methods

**Returns**

`TAccess` extends [`write`](/sdks/firmhouse-sdk/reference/enumerations/access.md#write) ? \[`invoices-resource`]../resources/(invoices.md) : `never`

***

#### projects

```ts
get projects(): TAccess extends write ? Projects : never
```

Project methods

**Returns**

`TAccess` extends [`write`](/sdks/firmhouse-sdk/reference/enumerations/access.md#write) ? \[`projects-resource`]../resources/(projects.md) : `never`

***

#### subscriptions

```ts
get subscriptions(): TAccess extends write ? Subscriptions : never
```

Subscription methods.

**Returns**

`TAccess` extends [`write`](/sdks/firmhouse-sdk/reference/enumerations/access.md#write) ? \[`subscriptions-resource`]../resources/(subscriptions.md) : `never`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.firmhouse.com/sdks/firmhouse-sdk/reference/classes/firmhouse-client.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
