Get user data
Prerequisites
- Merchant API key
- Bearer token (obtained from user authentication)
Goals
- Retrieve user profile data (email, address, customer type)
- Discover which channels and markets the user is allowed to use
- Use the available channels and markets to make valid API calls on behalf of the user
Architecture at a glance
- Authenticate user → call
getUserquery → read profile andavailableChannels→ use valid channel/market in subsequent API calls
APIs used
- Merchant API:
https://merchantapi.geins.io/graphql
Step-by-step
Get user profile and available channels
Use the getUser query to retrieve the authenticated user's profile data together with the channels and markets the user is allowed to use.
Request example
query getUser(
$channelId: String
$languageId: String
$marketId: String
) {
getUser(
channelId: $channelId
languageId: $languageId
marketId: $marketId
) {
id
email
customerType
address {
firstName
lastName
company
}
availableChannels {
channelId
availableMarkets {
id
alias
country {
name
code
}
currency {
code
}
allowedLanguages {
id
}
}
}
}
}
{
"Accept": "application/json",
"X-ApiKey": "{MERCHANT_API_KEY}",
"Authorization": "Bearer {JWT_BEARER_TOKEN}"
}
{
"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":"query getUser($channelId: String, $languageId: String, $marketId: String) { getUser(channelId: $channelId, languageId: $languageId, marketId: $marketId) { id email customerType address { firstName lastName company } availableChannels { channelId availableMarkets { id alias country { name code } currency { code } allowedLanguages { id } } } } }","variables":{"channelId":"{CHANNEL_ID}","languageId":"{LANGUAGE_ID}","marketId":"{MARKET_ID}"}}'
channelId, languageId, and marketId arguments are optional and can be left out to use default values.Response example
200 OK{
"data": {
"getUser": {
"id": 12345,
"email": "buyer@example.com",
"customerType": "PERSON",
"address": {
"firstName": "Jane",
"lastName": "Doe",
"company": "Acme Corp"
},
"availableChannels": [
{
"channelId": "1|se",
"availableMarkets": [
{
"id": "SE|SEK",
"alias": "se",
"country": { "name": "Sweden", "code": "SE" },
"currency": { "code": "SEK" },
"allowedLanguages": [
{ "id": "sv-SE" },
{ "id": "en-US" }
]
}
]
},
{
"channelId": "2|eu",
"availableMarkets": [
{
"id": "EU|EUR",
"alias": "eu",
"country": { "name": "Germany", "code": "DE" },
"currency": { "code": "EUR" },
"allowedLanguages": [
{ "id": "en-US" }
]
}
]
}
]
}
}
}
Use available channels and markets in subsequent calls
The availableChannels array lists every channel the user is permitted to access, along with the markets within each channel. Use these values as channelId and marketId in subsequent API calls to ensure valid requests.
This is particularly important for company buyers. A company can restrict its buyers to specific channels and markets. If you pass a channel or market that the buyer is not allowed to use, the API may return empty results or invalid data.
A typical flow after login:
- Call
getUserand readavailableChannels. - If the user has access to more than one channel or market, let them choose (or select a default).
- Pass the chosen
channelIdandmarketId(use the marketalias) to all subsequent queries and mutations (products, cart, checkout, orders).
Options
Multi-market support
The getUser query accepts optional localization arguments:
channelId— target a specific sales channel (e.g.,1|se)marketId— target a specific market using its alias (e.g.,se)languageId— target a specific language (e.g.,sv-SE)
Authenticated access
The getUser query requires a valid Bearer token. Include it as Authorization: Bearer {JWT_BEARER_TOKEN} in the HTTP headers alongside the X-ApiKey.
Common pitfalls
- Missing
Authorizationheader —getUserrequires authentication and will fail without a Bearer token. - Expired Bearer token — tokens expire after 15 minutes; implement refresh logic as needed.
- Ignoring
availableChannelsfor company buyers — passing a channel or market the buyer is not allowed to use can result in empty or invalid responses from other API calls.