Request

Response

    Usage Query Information

    Before You Begin

    Make sure that you have registered an app. and successfully acquired an OAuth token with the data:write scope.

    Note: This API is available to Premium Team admins only.

    Step 1: Obtaining an Access Token

    All calls to the Export Data API must be authenticated and a valid access token is required for each API call. Please refer to this walkthrough on how an access token can be obtained.

    Step 2: Submit Query request

    The Usage-query API exposes a POST /usage-queries endpoint that allows for the submission of usage-query requests. Usage-query’s are processed asynchronously. This endpoint returns an query Id, which is then used with the GET /usage-queries/:queryId endpoint to check the status and retrieve the results.

    Example Request

    Here is an example request to query uniqueUsers count, for all specific context managed by the logged in user.

    curl  -X POST \
          'https://developer.api.autodesk.com/insights/v1/usage-queries?offset=0&limit=100&context=4314051' \
          -H 'Content-Type: application/json' \
          -H 'Authorization: Bearer eyJhbGciOiJIUzI1N' \
          -d '{
          "fields": ["productName"],
          "metrics": ["uniqueUsers"],
          "where": "",
          "orderBy": "",
          "context": "4314051"
          }'
    
    Show More

    Note that line breaks have been added to the cURL command above for ease of reading. Make sure to remove them before executing any code in your terminal.

    If successful, the response body looks like:

    {
      "id": "6162f82d13b04dae36251a1dd78c790aedb99a75be4776f4871db117f344108d",
      "status": "SUBMITTED",
      "startTime": 1636578859
    }
    

    The response contains a id field, which is vital information to be used for the next step. Response shows the request SUBMITTED.

    Step 3: Get specific Usage-query Results

    Using the id value returned in Step 2, poll the GET /usage-queries/:queryId endpoint to check the status of the export. A status of ERROR indicates that the query failed due to an error; SUBMITTED indicates that the export is queued, and the result is not yet available.

    Example Request

    Here is an example to get Query Result for a specific Id (queryId).

    curl  -X GET \
          'https://developer.api.autodesk.com/insights/v1/usage-queries/6162f82d13b04dae36251a1dd78c790aedb99a75be4776f4871db117f344108d' \
          -H 'Content-Type: application/json' \
          -H 'Authorization: Bearer eyJhbGciOiJIUzI1N'
    

    Note that line breaks have been added to the cURL command above for ease of reading. Make sure to remove them before executing any code in your terminal.

    If successful, the response body looks like:

    {
      "id": "6162f82d13b04dae36251a1dd78c790aedb99a75be4776f4871db117f344108d",
      "status": "COMPLETED",
      "columns": [
          "productName",
          "uniqueUsers"
      ],
      "pagination": {
          "totalResults": 5,
          "offset": 0,
          "limit": 100
      },
      "rows": [
          [
              "3ds Max",
              1
          ],
          [
              "AutoCAD",
              2
          ],
          [
              "AutoCAD Electrical",
              2
          ],
          [
              "Maya",
              1
          ],
          [
              "Product Design & Manufacturing Collection",
              3
          ]
      ]
    }
    
    Show More

    Response shows query request successfully COMPLETED. This response gives 5 rows for uniqueUsers by productName.