How to

Get company orders

Retrieve order history for all buyers in a company account using Geins Merchant API.

Prerequisites

  • Merchant API key (X-ApiKey)
  • Authenticated user session (JWT bearer token)
  • User associated with a company account

Goals

  • Fetch all orders placed by any buyer in the authenticated user's company
  • Display a company-wide order history overview
  • Understand how company orders differ from individual user orders

Architecture at a glance

  • Authenticate company user → Query getCompanyOrders → Receive orders from all company buyers

APIs used

  • Merchant API: https://merchantapi.geins.io/graphql

Step-by-step

Query company orders

The getCompanyOrders query returns orders placed by all buyers linked to the authenticated user's company — not just the current user's own orders. This is the key difference from getOrders, which only returns the individual user's orders.

If the authenticated user is not a member of a company, the query returns an empty list.

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

Request example

query getCompanyOrders(
  $channelId: String
  $languageId: String
  $marketId: String
) {
  getCompanyOrders(
    channelId: $channelId
    languageId: $languageId
    marketId: $marketId
  ) {
    id
    publicId
    createdAt
    status
    orderTotal {
      sellingPriceIncVat
      sellingPriceIncVatFormatted
    }
    currency
    cart {
      items {
        id
      }
    }
    shippingAddress {
      firstName
      lastName
      company
      addressLine1
      city
      zip
      country
    }
  }
}
The channelId, languageId, and marketId arguments are optional and can be omitted to use default values.

Response example

200 OK
response.json
{
  "data": {
    "getCompanyOrders": [
      {
        "id": 12345,
        "publicId": "ORD-2025-001234",
        "createdAt": "2025-10-25T14:30:00Z",
        "status": "Shipped",
        "orderTotal": {
          "sellingPriceIncVat": 4500.00,
          "sellingPriceIncVatFormatted": "4,500.00 SEK"
        },
        "currency": "SEK",
        "cart": {
          "items": [
            { "id": 1 },
            { "id": 2 }
          ]
        },
        "shippingAddress": {
          "firstName": "Anna",
          "lastName": "Svensson",
          "company": "Acme Trading AB",
          "addressLine1": "Industrivägen 10",
          "city": "Stockholm",
          "zip": "11122",
          "country": "SE"
        }
      },
      {
        "id": 12340,
        "publicId": "ORD-2025-001229",
        "createdAt": "2025-09-15T10:15:00Z",
        "status": "Delivered",
        "orderTotal": {
          "sellingPriceIncVat": 1899.00,
          "sellingPriceIncVatFormatted": "1,899.00 SEK"
        },
        "currency": "SEK",
        "cart": {
          "items": [
            { "id": 1 }
          ]
        },
        "shippingAddress": {
          "firstName": "Erik",
          "lastName": "Johansson",
          "company": "Acme Trading AB",
          "addressLine1": "Lagervägen 5",
          "city": "Stockholm",
          "zip": "11133",
          "country": "SE"
        }
      }
    ]
  }
}

Combine with individual order details

Use getOrder with a specific orderId from the list to retrieve full details for any company order — including payment, shipping, and refund information.

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

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
    orderTotal {
      sellingPriceIncVat
      sellingPriceExVat
      vat
    }
    shippingAddress {
      firstName
      lastName
      company
      addressLine1
      city
      zip
      country
    }
    paymentDetails {
      displayName
    }
    shippingDetails {
      name
      parcelNumber
      trackingLink
    }
  }
}
Company members can view order details for any order placed by a buyer within the same company, not only their own orders.

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",
      "orderTotal": {
        "sellingPriceIncVat": 4500.00,
        "sellingPriceExVat": 3600.00,
        "vat": 900.00
      },
      "shippingAddress": {
        "firstName": "Anna",
        "lastName": "Svensson",
        "company": "Acme Trading AB",
        "addressLine1": "Industrivägen 10",
        "city": "Stockholm",
        "zip": "11122",
        "country": "SE"
      },
      "paymentDetails": {
        "displayName": "Invoice"
      },
      "shippingDetails": {
        "name": "Standard Shipping",
        "parcelNumber": "TRK987654321SE",
        "trackingLink": "https://tracking.example.com/TRK987654321SE"
      }
    }
  }
}

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.

Authenticated access

Authentication is required for this endpoint. The getCompanyOrders query uses the JWT bearer token to identify the user's company membership and retrieve all orders placed under that company. Without a valid 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

  • Confusing getCompanyOrders with getOrdersgetOrders returns only the individual user's orders. getCompanyOrders returns orders placed by all buyers in the company. Use Get user orders for personal order history.
  • User not linked to a company — If the authenticated user has no company account, the query returns an empty list rather than an error.
  • Missing JWT token — This query requires authentication. An API key alone is not sufficient; include the Authorization: Bearer header.
Related