Invalid API token + tried python script with same token

Topic summary

PUT to the Admin API from a Shopify admin workflow to tag an order returns 401 “Invalid API key or access token,” while the same token and URL work from a Python script (API 2023-10, header X-Shopify-Access-Token).

Key likely issues and fixes:

  • Use the correct order identifier for REST: {{ order.legacyResourceId }} instead of {order.id} in the URL. Flow variables must be wrapped in double curly braces {{ }}; single braces won’t resolve and can produce a bad URL.
  • Ensure credentials come from a custom app with the required Admin API write scopes, and use that app’s Admin API access token in the request.

No confirmation from the original poster that these changes resolved the error. Status: unresolved/awaiting feedback.

Summarized with AI on January 10. AI used: gpt-5.

Hi everyone! I am getting this response when I do a PUT request to this URL: “url”:“https://shop_name.myshopify.com/admin/api/2023-10/orders/{order.id}.json

I am trying to add an order tag.

I get this response.

{“status”:401,“response_body”:“{"errors":"[API] Invalid API key or access token (unrecognized login or wrong password)"}”,

I ran a python script with the same exact Admin API access token and it worked, same URL, same everything. I just wanted to get this to work as an automation and it does not work in the shopify admin workflows.

I am using this key ‘X-Shopify-Access-Token’

Does anyone have any ideas?

Any help??? I would love anything from anyone

You need to use legacyResourceId not id in URLs.

In order to output a variable, it must be enclosed in {{ }} not { }. So replace that with :

{{ order.legacyResourceId }}

For the API key, you need to create a custom app api key that has the write scopes and use the key there.