Skip to main content

Shop Users API

The Shop Users API is a GraphQL API scoped to an individual Shop user. Use it to read and write metafields that your app owns on a Shop user's profile. You authenticate with a user access token obtained from the Shop Partners API.

The Shop Users API uses Bearer token authentication. You get user access tokens by calling the fetchTokensForUser mutation on the Shop Partners API.

  1. Authenticate with the Partners API using your client credentials.
  2. Call fetchTokensForUser with the user's public ID to get an accessToken and refreshToken.
  3. Include the access token as a Bearer token in the Authorization header on all Users API requests.

cURL

curl -X POST \
https://shop.app/api/users/graphql.json \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-d '{
"query": "{ metafields(first: 10) { nodes { definition { namespace key } value } } }"
}'

Access tokens expire after a set time. When a token expires, use the refreshToken to get a new one.


Anchor to Endpoints and queriesEndpoints and queries

Send POST requests to the Users API endpoint:

https://shop.app/api/users/graphql.json

All requests must include a Content-Type: application/json header and a JSON body with a query field containing your GraphQL query or mutation.


Read and write custom data on the authenticated user's profile. Metafield definitions are created through the Shop Partners API, and you can read or write values for those definitions through the Users API.

QueryDescription
metafieldRetrieve a single metafield by key
metafieldsList metafields with pagination and filtering
MutationDescription
metafieldsSetSet or update metafield values on the user
metafieldDeleteDelete a metafield from the user

Metafield definitions are created and managed through the Shop Partners API.


Was this page helpful?