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

# productMetafieldKnowledgeReplace

> Set which metafields Commerce Agent reads, as the Products tab's metafield save does: the entries replace the store's whole set in one transaction, and an empty list turns metafield knowledge off. At most 5, as the Products tab allows, since every product Commerce Agent looks up carries them all; a store that already has more may keep that many. More fail with BAD_USER_INPUT. Two with one display name fail with BAD_USER_INPUT; a definition the store hasn't defined fails with NOT_FOUND, and nothing is written. It goes live at once, so it needs `commerce_agent_knowledge_publish`; `commerce_agent_knowledge_write` alone is refused with INSUFFICIENT_SCOPE.

**Required scopes:** [`commerce_agent_knowledge_publish`](https://developers.redo.com/docs/api-reference/v3/reference/scopes#scope-commerce_agent_knowledge_publish)

## Arguments

**entries** `[\[ProductMetafieldKnowledgeInput!\]!](/docs/api-reference/v3/reference/commerce-agent/product-metafield-knowledge-input)` *required*

**fields**

**definitionId** `ID!` *required*

The metafield's `ProductMetafieldDefinition.id`.

**displayName** `String`

What Commerce Agent calls it, at most 100 characters, unique among the entries. Omitted or null, its Shopify name.

**instructions** `String!` *required*

How Commerce Agent should use the value, at most 1000 characters.

## Returns

**productMetafieldKnowledgeReplace** `[\[ProductMetafieldKnowledge!\]!](/docs/api-reference/v3/reference/commerce-agent/product-metafield-knowledge)` *required*

A metafield Commerce Agent reads when it looks up a product, with the merchant's guidance, as the Products tab configures it.

**fields**

**createdAt** `[DateTime!](/docs/api-reference/v3/reference/common/date-time)` *required*

When it was added.

**definition** `[ProductMetafieldDefinition!](/docs/api-reference/v3/reference/commerce-agent/product-metafield-definition)` *required*

The metafield.

**fields**

**id** `ID!` *required*

The metafield definition's id, which `productMetafieldKnowledgeReplace` takes.

**key** `String!` *required*

Its Shopify key.

**name** `String!` *required*

Its Shopify name.

**namespace** `String!` *required*

Its Shopify namespace.

**owner** `[ProductMetafieldOwner!](/docs/api-reference/v3/reference/commerce-agent/product-metafield-owner)` *required*

Whether it's a product or a variant metafield.

**displayName** `String`

The merchant's name for it. Null when Commerce Agent uses its Shopify name.

**instructions** `String!` *required*

How Commerce Agent should use the value.

**name** `String!` *required*

What Commerce Agent calls it: `displayName`, else the metafield's Shopify name.

**updatedAt** `[DateTime!](/docs/api-reference/v3/reference/common/date-time)` *required*

When it last changed.

## Errors

Besides the [errors any request can return](https://developers.redo.com/docs/api-reference/v3/errors.md), this operation fails with these codes in `extensions.code`.

| Code | HTTP status | Meaning | Retry |
| - | - | - | - |
| `BAD_USER_INPUT` | `400` | An argument is invalid, or names something the store doesn't have. The message says which. Nothing was written. | Fix the input the message names, then send it again. |
| `NOT_FOUND` | `404` | An id the request refers to, other than its target, doesn't exist in the store. A missing target returns null instead. | Use an id that exists in the store. |
| `INTERNAL_SERVER_ERROR` | `500` | Something failed on Redo's side. The change may or may not have been made. | Read the record to see whether the change was made before sending it again. A send with an idempotencyKey is safe to retry with the same key. |

## Example

```graphql theme={null}
mutation {
  productMetafieldKnowledgeReplace(entries: { ... }) {
    createdAt
    displayName
    instructions
    name
    updatedAt
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.