How to
Get user orders
Retrieve order history and details for authenticated users using Geins Merchant API
Overview
Learn how to retrieve order information for authenticated users. This guide covers fetching a list of all orders and getting detailed information about a specific order.
This query returns orders for the individual user only. To retrieve orders placed by all buyers in a company, use Get company orders instead.
Prerequisites
- Merchant API key
- JWT token for authenticated user
Goal
- Fetch list of all orders for the current user
- Display order history with basic information
- Get detailed information about a specific order
Architecture at a glance
- Authenticate user → Get orders list → Display overview → Get order details → Show full information
Step-by-step
Get all orders for the current user
Retrieve a list of all orders placed by the authenticated user.
Try it out in the GraphQL Playground using the query, headers and variables below.
This query requires JWT authentication. Include the JWT token in the Authorization header.
Request example
query getOrders(
$channelId: String
$languageId: String
$marketId: String
) {
getOrders(
channelId: $channelId
languageId: $languageId
marketId: $marketId
) {
id
publicId
createdAt
status
orderTotal {
sellingPriceIncVat
sellingPriceIncVatFormatted
}
currency
cart {
items {
id
}
}
shippingAddress {
firstName
lastName
addressLine1
city
zip
country
}
}
}
{
"Accept": "application/json",
"Authorization": "Bearer {JWT_TOKEN}",
"X-ApiKey": "{MERCHANT_API_KEY}"
}
{
"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 "Authorization: Bearer {JWT_TOKEN}" \
-H "X-ApiKey: {MERCHANT_API_KEY}" \
-d '{"query":"query getOrders($channelId: String, $languageId: String, $marketId: String) { getOrders(channelId: $channelId, languageId: $languageId, marketId: $marketId) { id publicId createdAt status orderTotal { sellingPriceIncVat sellingPriceIncVatFormatted } currency cart { items { id } } shippingAddress { firstName lastName addressLine1 city zip country } } }","variables":{"channelId":"{CHANNEL_ID}","languageId":"{LANGUAGE_ID}","marketId":"{MARKET_ID}"}}'
Response example
200 OKresponse.json
{
"data": {
"getOrders": [
{
"id": 12345,
"publicId": "ORD-2025-001234",
"createdAt": "2025-10-25T14:30:00Z",
"status": "Shipped",
"orderTotal": {
"sellingPriceIncVat": 1299.00,
"sellingPriceIncVatFormatted": "1,299.00 SEK"
},
"currency": "SEK",
"cart": {
"items": [
{ "id": 1 },
{ "id": 2 },
{ "id": 3 }
]
},
"shippingAddress": {
"firstName": "John",
"lastName": "Doe",
"addressLine1": "Street Address 123",
"city": "Stockholm",
"zip": "12345",
"country": "SE"
}
},
{
"id": 12340,
"publicId": "ORD-2025-001229",
"createdAt": "2025-09-15T10:15:00Z",
"status": "Delivered",
"orderTotal": {
"sellingPriceIncVat": 599.00,
"sellingPriceIncVatFormatted": "599.00 SEK"
},
"currency": "SEK",
"cart": {
"items": [
{ "id": 1 }
]
},
"shippingAddress": {
"firstName": "John",
"lastName": "Doe",
"addressLine1": "Street Address 123",
"city": "Stockholm",
"zip": "12345",
"country": "SE"
}
}
]
}
}
Get detailed order information
Retrieve complete details about a specific order, including all items, pricing, and shipping information.
This query requires JWT authentication and the user must own the order being requested.
Request example
query getOrder(
$orderId: Int!
$channelId: String
$languageId: String
$marketId: String
) {
getOrder(
orderId: $orderId
channelId: $channelId
languageId: $languageId
marketId: $marketId
) {
id
publicId
createdAt
completedAt
status
message
desiredDeliveryDate
orderTotal {
sellingPriceIncVat
sellingPriceExVat
vat
isDiscounted
discountIncVat
}
shippingAddress {
firstName
lastName
company
addressLine1
addressLine2
city
zip
country
phone
}
paymentDetails {
displayName
}
shippingDetails {
name
parcelNumber
trackingLink
}
refunds {
id
createdAt
reason
}
}
}
{
"Accept": "application/json",
"Authorization": "Bearer {JWT_TOKEN}",
"X-ApiKey": "{MERCHANT_API_KEY}"
}
{
"orderId": 12345,
"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 "Authorization: Bearer {JWT_TOKEN}" \
-H "X-ApiKey: {MERCHANT_API_KEY}" \
-d '{"query":"query getOrder($orderId: Int!, $channelId: String, $languageId: String, $marketId: String) { getOrder(orderId: $orderId, channelId: $channelId, languageId: $languageId, marketId: $marketId) { id publicId createdAt completedAt status currency message desiredDeliveryDate orderTotal { sellingPriceIncVat sellingPriceExVat vat isDiscounted discountIncVat } shippingAddress { firstName lastName company addressLine1 addressLine2 city zip country phone } paymentDetails { displayName } shippingDetails { displayName parcelNumber trackingLink } refunds { id createdAt reason } } }","variables":{"orderId":12345,"channelId":"{CHANNEL_ID}","languageId":"{LANGUAGE_ID}","marketId":"{MARKET_ID}"}}'
Response example
200 OKresponse.json
{
"data": {
"getOrder": {
"id": 12345,
"publicId": "ORD-2025-001234",
"createdAt": "2025-10-25T14:30:00Z",
"completedAt": "2025-10-27T09:00:00Z",
"status": "Shipped",
"message": "Please leave package at reception",
"desiredDeliveryDate": "2025-10-30",
"orderTotal": {
"sellingPriceIncVat": 1299.00,
"sellingPriceExVat": 1039.20,
"vat": 259.80,
"isDiscounted": true,
"discountIncVat": 100.00
},
"shippingAddress": {
"firstName": "John",
"lastName": "Doe",
"company": "",
"addressLine1": "Street Address 123",
"addressLine2": "",
"city": "Stockholm",
"zip": "12345",
"country": "SE",
"phone": "+46701234567"
},
"paymentDetails": {
"displayName": "Card Payment"
},
"shippingDetails": {
"name": "Standard Shipping",
"parcelNumber": "TRK123456789SE",
"trackingLink": "https://tracking.example.com/TRK123456789SE"
},
"refunds": []
}
}
}
Options
Multi-market support
All queries support optional parameters for multi-market functionality:
channelId: Target specific sales channelslanguageId: Set content languagemarketId: Target specific markets
Authenticated access
Authentication is required for this endpoint. The getOrders query returns data scoped to the currently authenticated user. Without a valid JWT bearer token the request will fail with an authorization error.
Include the token in the Authorization header:
Authorization: Bearer {JWT_TOKEN}
See the authentication flow guide for details on obtaining and refreshing JWT tokens.
Common pitfalls
- Forgetting the JWT token — This query requires authentication. An API key alone is not sufficient; include the
Authorization: Bearerheader. - Expecting company-wide orders —
getOrdersonly returns the individual user's orders. For all orders across a company account, use Get company orders.
Related
Get user dataGet user ordersReset user passwordSubscribe to newsletterUpdate user dataUse multi-market supportGetOrderGetOrders