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.

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
    }
  }
}

Response example

200 OK
response.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
    }
  }
}

Response example

200 OK
response.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 channels
  • languageId: Set content language
  • marketId: Target specific markets
Read more about channelId, languageId, and marketId in the how-to about using multi-market support.

Redirect users to login page when receiving authentication errors.

Common pitfalls

  • Forgetting to include the JWT token in the Authorization header
Related