Error to add a metafield to a Return using GraphQL

Topic summary

A developer is encountering an “invalid id” error when attempting to attach a metafield to a Return object using the metafieldsSet GraphQL mutation. The mutation works successfully with Order objects but fails specifically for Returns.

Technical Details:

  • Using ownerId: "gid://shopify/Return/7148568894"
  • Mutation structure appears correct (namespace, key, value, type all properly defined)
  • Error occurs at the metafieldsSet operation itself

Use Cases:

  • Original poster needs to store additional custom information on Returns
  • Second user requires external event tracking and needs a reference field to identify the correct Return when processing close events

Current Status:

  • No solution has been identified
  • Unclear from documentation whether Returns support metafields at all
  • Alternative suggestion: potentially use the customerNote field on returnLineItems, though this may not fully address the requirements

Unresolved: The discussion remains open with no confirmed workaround or official clarification on Return metafield support.

Summarized with AI on October 26. AI used: claude-sonnet-4-5-20250929.

I’m trying to add a meta field on a Return using Graph but I get an invalid Id error, I couldn’t find in the documentation if a Return can have a meta field or not.

Mutation:

mutation metafieldsSet($metafields: [MetafieldsSetInput!]!) {
  metafieldsSet(metafields: $metafields) {
    metafields {
      id
      key
      namespace
      value
      type
    }
    userErrors {
      field
      message
    }
  }
}

Variables:

{
  "metafields": [
    {
      "ownerId": "gid://shopify/Return/7148568894",
      "namespace": "custom_notes",
      "key": "customer_note",
      "value": "This is a customer-provided note.",
      "type": "single_line_text_field"
    }
  ]
}

Response:

{
    "errors": [
        {
            "message": "invalid id",
            "locations": [
                {
                    "line": 3,
                    "column": 3
                }
            ],
            "path": [
                "metafieldsSet"
            ],
            "extensions": {}
        }
    ],
    "data": {
        "metafieldsSet": null
    },
    "extensions": {
        "cost": {
            "requestedQueryCost": 10,
            "actualQueryCost": 1,
            "throttleStatus": {
                "maximumAvailable": 2000.0,
                "currentlyAvailable": 1999,
                "restoreRate": 100.0
            }
        }
    }
}

I need to add some extra info on my Return that’s why I want to use meta field, if this is not possible will be helpful if I could add info on the returnLineItems edges nodes customerNote field on Return object.

Thank you in advance for any help.

I have exactly the same issue. If I do exactly the same but on an order it works as expected.
Did you ever found a solution.

What I’m trying to do:
I receive events from an external party, one of the events is to create a return and another event is to close the return. I need a reference to make sure I use the correct return.