Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Delete a metafield

Remove a metafield's value from Shopify.

DELETE /apps/raven/delete_metafield, taking raven_id and resource_id.

This clears the metafield on the resource. It does not remove the metafield definition you created in Shopify admin.

Sending the request

async function remove() {
  var cfg = window.FR_CUSTOMER_MY_KEY;              // from the Get Code panel

  var res = await fetch('/apps/raven/delete_metafield', {
    method: 'DELETE',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ raven_id: cfg.ravenId, resource_id: cfg.resourceId })
  });

  if (res.status === 429) {
    return console.warn('Throttled — retry after', res.headers.get('Retry-After'), 'seconds.');
  }
  var data = await res.json().catch(function () { return {}; });
  if (res.status === 503) {
    if (data.code === 'backlog_draining') {
      return console.warn('Earlier work is draining. Retry the delete later.');
    }
    if (data.code === 'reconnect_required') {
      return console.error('The store must reconnect. Check the metafield before retrying.');
    }
    if (data.code === 'upstream_unavailable') {
      return console.warn('Shopify is unavailable. Check the metafield, then retry later.');
    }
  }
  if (!res.ok) return console.error(data.message || 'Delete rejected.');
  console.log('Deleted.');
}

Responses worth handling

Status
Meaning

200

The metafield was removed from Shopify.

422

Rejected. Either raven_id/resource_id were missing or did not resolve on this shop, or Shopify refused the delete — in which case the message is Shopify's own.

429

Shopify throttled it. Retry-After carries the delay in seconds.

503

Check code: backlog_draining means retry later; reconnect_required means the store must reconnect; upstream_unavailable means Shopify or the connection was temporarily unavailable. Do not report the delete as successful.

The 503 response body is one of these exact JSON objects:

For backlog_draining, wait and retry later without asking the merchant to reconnect. For reconnect_required, ask the merchant or support to reconnect the store, then check whether the metafield was deleted before retrying; the delete may have failed after remote work began. For upstream_unavailable, retry later without asking the merchant to reconnect; a delete that timed out may still have completed, so check whether the metafield is gone first.

Last updated