How to
Update user data
Update user profile information including address, preferences, and metadata using Geins Merchant API
Prerequisites
- Merchant API key
- Bearer token (obtained from user authentication)
Learn how to obtain a Bearer token by following the Log in user guide.
Goal
- Update user profile information
Architecture at a glance
- Use
updateUsermutation → Update profile data - Include Bearer token in
Authorization: Bearer {token}header for all requests
APIs used
- Merchant API:
https://merchantapi.geins.io/graphql
Step-by-step
Update basic user information
Use the updateUser mutation to modify user profile data:
Try it out in the GraphQL Playground using the query, headers and variables below.
Request example
mutation updateUser(
$user: UserInputType!
$channelId: String
$languageId: String
$marketId: String
) {
updateUser(
user: $user
channelId: $channelId
languageId: $languageId
marketId: $marketId
) {
id
email
gender
customerType
newsletter
personalId
}
}
{
"Accept": "application/json",
"X-ApiKey": "{MERCHANT_API_KEY}",
"Authorization": "Bearer {JWT_BEARER_TOKEN}"
}
{
"user": {
"gender": "WOMAN",
"newsletter": true,
"personalId": "19901231-1234",
"customerType": "PERSON",
},
"channelId": "{CHANNEL_ID}",
"languageId": "{LANGUAGE_ID}",
"marketId": "{MARKET_ID}"
}
curl -X POST https://merchantapi.geins.io/graphql \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-ApiKey: {MERCHANT_API_KEY}" \
-H "Authorization: Bearer {JWT_BEARER_TOKEN}" \
-d '{"query":"mutation updateUser($user: UserInputType!, $channelId: String, $languageId: String, $marketId: String) { updateUser(user: $user, channelId: $channelId, languageId: $languageId, marketId: $marketId) { id email gender customerType newsletter personalId } }","variables":{"user":{"gender":"WOMAN","newsletter":true,"personalId":"19901231-1234","customerType":"PERSON"},"channelId":"{CHANNEL_ID}","languageId":"{LANGUAGE_ID}","marketId":"{MARKET_ID}"}}'
The
channelId, languageId, and marketId arguments are optional and can be left out to use default values.Response example
200 OKresponse.json
{
"data": {
"updateUser": {
"id": 12345,
"email": "user@example.com",
"gender": "WOMAN",
"customerType": "PERSON",
"newsletter": true,
"personalId": "19901231-1234"
}
}
}
Update user address
Update address information for the user
Request example
mutation updateUser(
$user: UserInputType!
$channelId: String
$languageId: String
$marketId: String
) {
updateUser(
user: $user
channelId: $channelId
languageId: $languageId
marketId: $marketId
) {
address {
firstName
lastName
addressLine1
addressLine2
city
state
country
zip
company
mobile
phone
careOf
entryCode
}
}
}
{
"Accept": "application/json",
"X-ApiKey": "{MERCHANT_API_KEY}",
"Authorization": "Bearer {JWT_BEARER_TOKEN}"
}
{
"user": {
"address": {
"firstName": "Jane",
"lastName": "Doe",
"addressLine1": "456 New Street",
"addressLine2": "Apartment 2B",
"city": "Gothenburg",
"state": "Västra Götaland",
"country": "Sweden",
"zip": "41234",
"company": "Tech Solutions AB",
"mobile": "+46 70 987 654 32",
"phone": "+46 31 123 456 78",
"careOf": "John Smith",
"entryCode": "1234"
}
},
"channelId": "{CHANNEL_ID}",
"languageId": "{LANGUAGE_ID}",
"marketId": "{MARKET_ID}"
}
curl -X POST https://merchantapi.geins.io/graphql \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-ApiKey: {MERCHANT_API_KEY}" \
-H "Authorization: Bearer {JWT_BEARER_TOKEN}" \
-d '{"query":"mutation updateUser($user: UserInputType!, $channelId: String, $languageId: String, $marketId: String) { updateUser(user: $user, channelId: $channelId, languageId: $languageId, marketId: $marketId) { address { firstName lastName addressLine1 addressLine2 city state country zip company mobile phone careOf entryCode } } }","variables":{"user":{"address":{"firstName":"Jane","lastName":"Doe","addressLine1":"456 New Street","addressLine2":"Apartment 2B","city":"Gothenburg","state":"Västra Götaland","country":"Sweden","zip":"41234","company":"Tech Solutions AB","mobile":"+46 70 987 654 32","phone":"+46 31 123 456 78","careOf":"John Smith","entryCode":"1234"}},"channelId":"{CHANNEL_ID}","languageId":"{LANGUAGE_ID}","marketId":"{MARKET_ID}"}}'
Update customer type
Change user from person to organization:
Request example
{
"user": {
"customerType": "ORGANIZATION",
"address": {
"company": "Acme Corporation AB",
"firstName": "Jane",
"lastName": "Doe"
}
}
}
User input options
The updateUser mutation accepts the following user data:
Basic information
gender: Set toUNSET,UNSPECIFIED,WOMAN, orMANnewsletter: Boolean for newsletter subscriptionpersonalId: Personal identification number or social security numbercustomerType: Set toPERSONorORGANIZATION(defaults toPERSON)metaData: JSON string for storing custom user preferences or data
Address information
All address fields are optional:
firstName,lastName: User's nameaddressLine1,addressLine2,addressLine3: Street address linescity,state,country: Location informationzip: Postal codecompany: Company name (especially useful forORGANIZATIONcustomer type)mobile,phone: Contact numberscareOf: Care of address informationentryCode: Building or gate entry code
Multi-market support
The mutation supports optional parameters for multi-market configurations:
Common pitfalls
- Missing to add
Authorizationheader with Bearer token - Invalid
customerTypeenum values - usePERSONorORGANIZATIONonly - Invalid
genderenum values - useUNSET,UNSPECIFIED,WOMAN, orMAN
Related docs
- Authentication guide: Log in user
- Token refresh guide: Refresh user token
- Registration guide: Register user
Related
Authentication flowChange user passwordGet user ordersLog in userLog out userRefresh user tokenRegister userReset user passwordUpdateUser