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
getquery → read profile andUser available→ use valid channel/market in subsequent API callsChannels
APIs used
- Merchant API:
https://merchantapi.geins.io/graphql
Step-by-step
Get user profile and available channels
Use the get 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 available array lists every channel the user is permitted to access, along with the markets within each channel. Use these values as channel and market 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
getand readUser available.Channels - If the user has access to more than one channel or market, let them choose (or select a default).
- Pass the chosen
channelandId market(use the marketId alias) to all subsequent queries and mutations (products, cart, checkout, orders).
Options
Multi-market support
The get query accepts optional localization arguments:
channel— target a specific sales channel (e.g.,Id 1|se)market— target a specific market using its alias (e.g.,Id se)language— target a specific language (e.g.,Id sv-SE)
Authenticated access
The get query requires a valid Bearer token. Include it as Authorization: Bearer {JWT_BEARER_TOKEN} in the HTTP headers alongside the X-Api.
Common pitfalls
- Missing
Authorizationheader —getrequires authentication and will fail without a Bearer token.User - Expired Bearer token — tokens expire after 15 minutes; implement refresh logic as needed.
- Ignoring
availablefor 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.Channels