> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-typedoc-upgrade.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# withAttributes

> TypeScript SDK reference

> **withAttributes**\<`T`>(`attrs`, `fn`): `T` | `Promise`\<`T`>

Defined in: [src/clientApi.ts:209](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/clientApi.ts#L209)

Attach attributes to the current execution context so that any calls created
inside `fn` automatically inherit them. Attributes are written to the call
record on the trace server and surface in the Weave UI/filtering, so they’re
ideal for tagging runs with request IDs, tenants, experiments, etc.

Example:

```ts twoslash theme={null}
// @noErrors
await withAttributes({requestId: 'abc'}, async () => {
  await myOp();
});
```

## Type Parameters

### T

`T`

## Parameters

### attrs

`Record`\<`string`, `any`>

### fn

() => `T` | `Promise`\<`T`>

## Returns

`T` | `Promise`\<`T`>
