***

title: setMetadata
slug: /reference/typescript/agents/function-result/set-metadata
description: Set function-scoped metadata key-value pairs.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[functionresult]: /docs/server-sdks/reference/typescript/agents/function-result

Set function-scoped metadata key-value pairs. Metadata is scoped to the current
function's `meta_data_token`, so each function maintains its own independent
metadata store. Maps to the `set_meta_data` SWML action.

## **Parameters**

<ParamField path="data" type={"Record<string, unknown>"} required={true} toc={true}>
  Object of key-value pairs to store as metadata.
</ParamField>

## **Returns**

[`FunctionResult`][functionresult] -- `this`, for chaining.

## **Example**

```typescript {4}
import { FunctionResult } from '@signalwire/sdk';

const result = new FunctionResult()
  .setMetadata({ department: 'sales', priority: 'high' });
```