Sales Data

Authentication: All endpoints require an Authorization: Bearer <access token> header.

Most endpoints require an X-Company-ID: <company_id> header to scope requests to a specific company. This is the recommended header for most API operations.

Some endpoints require an X-Location-ID: <location_id> header when the query doesn't accept a locationId parameter.

See Authentication for details on how to obtain and use these headers.

Query Sales Data

GraphQL Query

query SalesForecast($startTime: DateTime!, $endTime: DateTime!) {
  locationSales(startTime: $startTime, endTime: $endTime) {
    day
    forecast
    actual
    hours
    cost
  }
}

Example Variables

{
  "startTime": "2024-05-18T16:00:00.000Z",
  "endTime": "2024-05-26T17:59:59.000Z"
}

Example Response

{
  "data": {
    "locationSales": [
      {
        "day": "2024-05-19",
        "forecast": 190000,
        "actual": 240000,
        "hours": 0,
        "cost": 0
      },
      {
        "day": "2024-05-20",
        "forecast": 170000,
        "actual": 165000,
        "hours": 24,
        "cost": 0
      },
      {
        "day": "2024-05-21",
        "forecast": 165000,
        "actual": 175500,
        "hours": 28,
        "cost": 0
      },
      {
        "day": "2024-05-22",
        "forecast": 120000,
        "actual": 145000,
        "hours": 24,
        "cost": 0
      },
      {
        "day": "2024-05-23",
        "forecast": 195000,
        "actual": 176500,
        "hours": 29,
        "cost": 0
      },
      {
        "day": "2024-05-24",
        "forecast": 238500,
        "actual": 212500,
        "hours": 36,
        "cost": 0
      }
    ]
  }
}

Import Sales Data

GraphQL Mutation

mutation ImportSalesData($data: String!, $columns: [String!]!, $hourly: Boolean!) {
  importSalesData(data: $data, columns: $columns, hourly: $hourly) {
    completed
    message
    errors
  }
}

Example Variables

{
  "data": "Date (eg. 2018-08-22 or 2018-08-22 09:00 am),Location ID,Forecast Sale,Actual Sale,Budget Hours,Budget Cost,Forecast Units,Actual Units\r\n2024-05-15,12325,1350,1480,0,0,10,12\r\n2024-05-16,12325,1270,1320,0,0,13,12\r\n2024-05-17,12325,1500,1460,0,0,20,30\r\n2024-05-18,12325,1760,1750,0,0,12,10\r\n2024-05-19,12325,1900,2400,0,0,30,30\r\n",
  "columns": ["date", "location", "forecast", "actual", "hours", "cost", "forecast_units", "actual_units"],
  "hourly": false
}

Example Response

{
  "data": {
    "importSalesData": {
      "completed": true,
      "message": "Data imported successfully.",
      "errors": []
    }
  }
}

Update Sales Data

GraphQL Mutation

mutation UpdateSalesData($input: [UpdateSalesDataInput!]!) {
  updateSalesData(input: $input) {
    id
  }
}

Example Variables

{
  "input": [
    {
      "day": "2024-05-20",
      "forecast": 1700,
      "actual": 1650,
      "cost": 0,
      "hours": 24
    },
    {
      "day": "2024-05-21",
      "forecast": 1650,
      "actual": 1755,
      "cost": 0,
      "hours": 28
    },
    {
      "day": "2024-05-22",
      "forecast": 1200,
      "actual": 1450,
      "cost": 0,
      "hours": 24
    },
    {
      "day": "2024-05-23",
      "forecast": 1950,
      "actual": 1765,
      "cost": 0,
      "hours": 29
    },
    {
      "day": "2024-05-24",
      "forecast": 2385,
      "actual": 2125,
      "cost": 0,
      "hours": 36
    }
  ]
}

Example Response

{
  "data": {
    "updateSalesData": [
      {
        "id": "1582"
      },
      {
        "id": "1583"
      },
      {
        "id": "1584"
      },
      {
        "id": "1585"
      },
      {
        "id": "1586"
      }
    ]
  }
}