how to update customer tag usign api.

plz check the image it’s give errro

plz . give me any method where i can update customer tag name

Hey @yingdanong ,

You can update a customer’s tags in Shopify using the Admin API. This can be done using either the REST API or GraphQL API.

  1. Using REST API:

Endpoint:

PUT /admin/api/2024-04/customers/{customer_id}.json

Request:

{
  "customer": {
    "id": 1234567890,
    "tags": "VIP, Returning Customer"
  }
}

cURL Example:

curl -X PUT "https://{shop}.myshopify.com/admin/api/2024-04/customers/{customer_id}.json" \
-H "Content-Type: application/json" \
-H "X-Shopify-Access-Token: {access_token}" \
-d '{
  "customer": {
    "id": 1234567890,
    "tags": "VIP, Returning Customer"
  }
}'
  1. Using GraphQL API:

Mutation:

mutation {
  customerUpdate(input: {
    id: "gid://shopify/Customer/1234567890",
    tags: ["VIP", "Returning Customer"]
  }) {
    customer {
      id
      tags
    }
    userErrors {
      field
      message
    }
  }
}

cURL Example:

curl -X POST "https://{shop}.myshopify.com/admin/api/2024-04/graphql.json" \
-H "Content-Type: application/json" \
-H "X-Shopify-Access-Token: {access_token}" \
-d '{
  "query": "mutation { customerUpdate(input: { id: \"gid://shopify/Customer/1234567890\", tags: [\"VIP\", \"Returning Customer\"] }) { customer { id tags } userErrors { field message } } }"
}'

How It Works:

  • REST API: Sends a PUT request to update the customer’s tags. This replaces the existing tags.

  • GraphQL API: Uses the customerUpdate mutation to update tags.

If you want me to implement this for you, please feel free to reach out in my signature below—I’d be happy to help! Thanks.

If I was able to help you, please don’t forget to Like and mark it as the Solution!

Best,

Rajat

[Shopify Expert]

how to get customer information ?

You can get customer information using Shopify’s Admin API via REST or GraphQL:

  • REST API: GET /admin/api/2024-04/customers/{customer_id}.json

  • GraphQL API: Query customer details with specific fields.

Let me know if you need help implementing this—I’d be happy to assist!