How to

Get user data

Retrieve authenticated user profile and available channels and markets 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.

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 getUser query → read profile and availableChannels → 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.

Try it out in the GraphQL Playground using the query, headers and variables below.

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
        }
      }
    }
  }
}
The channelId, languageId, and marketId arguments are optional and can be left out to use default values.

Response example

200 OK
response.json
{
  "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:

  1. Call getUser and read availableChannels.
  2. If the user has access to more than one channel or market, let them choose (or select a default).
  3. Pass the chosen channelId and marketId (use the market alias) 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)
Read more about channelId, languageId, and marketId in the multi-market support guide.

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.

See the full Authentication flow guide for details on obtaining and refreshing tokens.

Common pitfalls

  • Missing Authorization header — getUser requires authentication and will fail without a Bearer token.
  • Expired Bearer token — tokens expire after 15 minutes; implement refresh logic as needed.
  • Ignoring availableChannels for 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.
Related