> Index of every page on this site: [llms.txt](https://kubb.dev/llms.txt)

# Call operations

Call a generated function with one grouped options object. It returns your client's promise, shaped by your `RequestResult` type.

```typescript
import { addPet, getPetById } from './gen/clients'

const created = await addPet({ body: { name: 'Odie', photoUrls: [] } })
console.log(created.data, created.response.status)

const pet = await getPetById({ path: { petId: 1 } })
```

The examples set [`integerType: 'number'`](https://kubb.dev/extensions/kubb-labs/adapter-oas/options#integertype) on the adapter. Without it, `petId` is a `bigint` and takes `1n`.

| Key                                           | Holds                                                                                                                             |
| --------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `path`, `query`, `headers`, `cookies`, `body` | The request values, typed from the spec.                                                                                          |
| `throwOnError`                                | Overrides [`throwOnErrorDefault`](https://kubb.dev/extensions/kubb-labs/plugin-client/options#throwonerrordefault) for this call. |
| `client`                                      | Another client function for this call, such as a signed or per-tenant client.                                                     |
| Any other key                                 | Passed to your client as is, such as `signal`.                                                                                    |

Path keys keep their spec names unless you set [`pathParamsCasing`](https://kubb.dev/extensions/kubb-labs/adapter-oas/options#pathparamscasing). See [Path parameter names](#path-parameter-names).

## Handle errors

Your client decides what `throwOnError` does. With the [client from scratch](https://kubb.dev/extensions/kubb-labs/plugin-client/guides/write-your-client#write-the-client), a non-2xx status throws, and `throwOnError: false` returns the error as a value:

```typescript
const result = await getPetById({ path: { petId: 1 }, throwOnError: false })

if (result.error === undefined) console.log('pet', result.data)
else console.log('failed', result.response.status)
```

Next, [validate requests and responses](https://kubb.dev/extensions/kubb-labs/plugin-client/guides/validate-requests-and-responses).

## Less common cases

### Path parameter names

When the spec names a path parameter in kebab or snake case, such as `{pet-id}`, the path key keeps that name: pass `path: { 'pet-id': 1 }`.

Set [`pathParamsCasing: 'camelcase'`](https://kubb.dev/extensions/kubb-labs/adapter-oas/options#pathparamscasing) on the adapter (`@kubb/adapter-oas` 5.20.0 or later) to pass `path: { petId: 1 }` instead. The HTTP request stays the same.

## Sitemap

See the full [sitemap](https://kubb.dev/sitemap.md) for all pages.
