Request

Response

    Subscribe to Element Group Extraction Status Events

    In this tutorial you will learn how to subscribe to element group extraction events instead of repeatedly polling the elementGroupExtractionStatus query.

    When a Revit model is synced or published to Forma Data Management, the AEC Data Model extracts the model data in the background. Subscriptions generate events for both workflows:

    • Work In Progress (sync) — when a user syncs a Revit cloud model to central.
    • Publish — when a user publishes a model to Forma Data Management.

    In either case, your application receives an event when extraction finishes. Today, many applications poll elementGroupExtractionStatus until extraction completes. With subscriptions, your application opens a single long-lived connection and waits for that event instead of polling.

    The steps include:

    1. Subscribing to extraction status events for a specific file.
    2. Understanding version information in the event.
    3. Querying element group data after extraction completes.
    4. Subscribing to extraction events for an entire project.
    5. Handling subscription disconnects in production applications.

    You can use the following subscriptions in this tutorial:


    TypeOperationDescription
    Subscription elementGroupExtractionStatusByFileUrn Subscribe to extraction events for a specific file URN in a project.
    Subscription elementGroupExtractionStatusByProject Subscribe to extraction events for all files in a project.

    Note

    Multipart response stream

    Subscriptions are delivered over HTTP using a multipart response stream. Unlike standard GraphQL queries, you must include a special Accept header on every subscription request. See the callout in Step 1 for the exact header value.

    Step 1: Subscribe to Extraction Status Events for a File

    The following steps demonstrate how to subscribe to extraction events for a specific Revit file using cURL.

    Before you begin, make sure you have:

    • A valid 3-legged OAuth access token. See Get a 3-Legged Token.
    • The accProjectId for your Forma project.
    • The fileUrn (lineage URN) for the Revit model you want to monitor.

    Important

    Required Accept header

    Every subscription request must include this Accept header:

    multipart/mixed;subscriptionSpec=1.0, application/json

    Without it, the server treats the request as a standard GraphQL query and does not stream subscription events.

    1. Run the following cURL command, replacing {{YOUR_ACCESS_TOKEN}}, {{YOUR_ACC_PROJECT_ID}}, and {{YOUR_FILE_URN}} with your values.

      Subscription

      subscription elementGroupExtractionStatusByFileUrn($input: ElementGroupExtractionByFileUrnInput!) {
          elementGroupExtractionStatusByFileUrn(input: $input) {
              status
              details
              elementGroup {
                  id
                  name
                  version {
                      versionNumber
                      wipVersionNumber
                  }
              }
          }
      }
      
      Show More

      Request

      curl 'https://developer.api.autodesk.com/aec/beta/graphql' -v \
        -H 'accept: multipart/mixed;subscriptionSpec=1.0, application/json' \
        -H 'content-type: application/json' \
        -H 'Authorization: Bearer {{YOUR_ACCESS_TOKEN}}' \
        --data-raw '{
          "query": "subscription ($input: ElementGroupExtractionByFileUrnInput!) { elementGroupExtractionStatusByFileUrn(input: $input) { status details elementGroup { id name version { versionNumber wipVersionNumber } } } }",
          "variables": {
            "input": {
              "accProjectId": "{{YOUR_ACC_PROJECT_ID}}",
              "fileUrn": "{{YOUR_FILE_URN}}"
            }
          }
        }'
      
      Show More
    2. Keep the connection open. The response is a multipart HTTP stream rather than a single JSON payload.

      While extraction is in progress, the stream sends periodic keep-alive parts. Each part looks like the following:

      --graphql
      content-type: application/json
      
      {}
      

      When extraction completes, one part contains the event payload:

      --graphql
      content-type: application/json
      
      {"payload":{"data":{"elementGroupExtractionStatusByFileUrn":{"status":"SUCCESS","details":null,"elementGroup":{"id":"YWVjZH5FQXVVdG1icWJCTkJIdUx4VkNTRkFjX0wyQ345YTUxZmRhMi0yYjg2LTU4ZjgtYTI4Yy1mMWZhZjVmNjhhYWY","name":"House - Event - Test-2.rvt","version":{"versionNumber":1,"wipVersionNumber":3}}}}}}
      

      Additional keep-alive parts may follow after the event.

    3. Parse the stream until you receive a part where payload.data.elementGroupExtractionStatusByFileUrn.status is SUCCESS. Keep-alive parts are empty {} objects—ignore them and continue reading.

    Possible status values


    StatusDescription
    SUCCESS Extraction completed successfully and a versioned snapshot is available to query.

    SUCCESS is the only status this subscription returns. The event is raised from the revision event for a versioned snapshot, which is emitted only once extraction has succeeded—so the subscription never reports IN_PROGRESS, and a failed extraction produces no event at all.

    This means the absence of an event is not by itself an error signal. If you expected an event and did not receive one, use the elementGroupExtractionStatus query to check the actual status of the extraction. That query returns the full ExtractionStatus set, including IN_PROGRESS and FAILED.

    Step 2: Understand Version Information in the Event

    When extraction succeeds, the subscription returns the elementGroup and its version information. The same subscription covers both Work In Progress and publish workflows—use the returned version fields to tell which kind of extraction completed.

    • wipVersionNumber — the Work In Progress version. This is updated when a user syncs a Revit cloud model to central.
    • versionNumber — the published (lineage) version. This is updated when a user publishes a model to Forma Data Management.

    These two numbers are independent—the same model can be at WIP version 8 and published version 3 at the same time.

    Depending on your workflow:

    • After a sync, wait for the subscription event and use the returned wipVersionNumber to query the extracted WIP version.
    • After a publish, wait for the subscription event and use the returned versionNumber to query the extracted published version.

    Both workflows use the same subscription—you do not need a separate subscription for sync versus publish. Subscribe once, wait for the event, then query your data. You still need elementGroupExtractionStatus to check extractions that never produce an event.

    Query either version with elementGroupByVersionNumber

    elementGroupByVersionNumber retrieves both version types—you do not need a different query for WIP versus published. The versionNumber argument carries the number, and the optional versionFilter argument tells the service which kind of number it is, using a VersionTypeEnum value:

    • versionType: WIP — resolve versionNumber as the Work In Progress (timeline) version. Pass the wipVersionNumber returned by the subscription.
    • versionType: PUBLISHED — resolve versionNumber as the published (lineage) version. Pass the versionNumber returned by the subscription.

    If you omit versionFilter, the service defaults to PUBLISHED.

    Query

    query elementGroupByVersionNumber($elementGroupId: ID!, $versionNumber: Int!, $versionFilter: VersionFilterInput) {
        elementGroupByVersionNumber(elementGroupId: $elementGroupId, versionNumber: $versionNumber, versionFilter: $versionFilter) {
            id
            name
            alternativeIdentifiers {
                fileVersionUrn
            }
            version {
                versionNumber
                wipVersionNumber
                createdOn
            }
        }
    }
    
    Show More

    Query Variables — WIP version after a sync

    {
        "elementGroupId": "{{YOUR_ELEMENT_GROUP_ID}}",
        "versionNumber": 8,
        "versionFilter": {
            "versionType": "WIP"
        }
    }
    

    Query Variables — published version after a publish

    {
        "elementGroupId": "{{YOUR_ELEMENT_GROUP_ID}}",
        "versionNumber": 3,
        "versionFilter": {
            "versionType": "PUBLISHED"
        }
    }
    

    Step 3: Query Element Group Data After Extraction Completes

    Once the subscription reports SUCCESS, use the elementGroup.id from the event to query model data—the same workflow you would follow after a successful elementGroupExtractionStatus poll. The subscription event confirms extraction is complete; from there you can run any query you would normally use against the element group.

    1. Enter the following query in the Query Pane of the AEC Data Model Explorer, or send it as a standard GraphQL POST request.

      Query

      query elementGroupAtTip($elementGroupId: ID!, $pagination: PaginationInput) {
          elementGroupAtTip(elementGroupId: $elementGroupId) {
              id
              name
              alternativeIdentifiers {
                  fileUrn
                  fileVersionUrn
              }
              version {
                  versionNumber
                  wipVersionNumber
              }
              elements(pagination: $pagination) {
                  results {
                      id
                      name
                      properties {
                          results {
                              name
                              value
                          }
                      }
                  }
              }
          }
      }
      
      Show More
    2. In the query variable pane enter the elementGroup.id value from the subscription event.

      Query Variables

      {
          "elementGroupId": "{{ELEMENT_GROUP_ID_FROM_SUBSCRIPTION_EVENT}}",
          "pagination": {
              "limit": 5
          }
      }
      
    3. Click Play. The response confirms the extracted element group is ready to query and returns element data with properties.

      Response

      {
          "data": {
              "elementGroupAtTip": {
                  "id": "YWVjZH5FQXVVdG1icWJCTkJIdUx4VkNTRkFjX0wyQ345YTUxZmRhMi0yYjg2LTU4ZjgtYTI4Yy1mMWZhZjVmNjhhYWY",
                  "name": "House - Event - Test-2.rvt",
                  "alternativeIdentifiers": {
                      "fileUrn": "urn:adsk.wipstg:dm.lineage:Ke918ItRRn6lXhsJh7pxoQ",
                      "fileVersionUrn": "urn:adsk.wipstg:fs.file:vf.Ke918ItRRn6lXhsJh7pxoQ?version=1"
                  },
                  "version": {
                      "versionNumber": 1,
                      "wipVersionNumber": 3
                  },
                  "elements": {
                      "results": [
                          {
                              "id": "YWVjZX5FQXVVdG1icWJCTkJIdUx4VkNTRkFjX0wyQ35hYWJjMTIzNC01Njc4LTkwYWItY2RlZi0wMTIzNDU2Nzg5YWI",
                              "name": "Basic Wall",
                              "properties": {
                                  "results": [
                                      {
                                          "name": "Category",
                                          "value": "Walls"
                                      },
                                      {
                                          "name": "Length",
                                          "value": 12.5
                                      }
                                  ]
                              }
                          },
                          {
                              "id": "YWVjZX5FQXVVdG1icWJCTkJIdUx4VkNTRkFjX0wyQ35hYWJjMTIzNC01Njc4LTkwYWItY2RlZi0wMTIzNDU2Nzg5YWM",
                              "name": "36\" x 84\"",
                              "properties": {
                                  "results": [
                                      {
                                          "name": "Category",
                                          "value": "Doors"
                                      },
                                      {
                                          "name": "Height",
                                          "value": 2.1336
                                      }
                                  ]
                              }
                          }
                      ]
                  }
              }
          }
      }
      
      Show More

      Additional elements in results use the same shape and are omitted here. You can add filters, pagination, and other fields the same way you would in any other tutorial—for example, see Get Elements from a Category.

    If you need a specific version rather than the tip, use elementGroupByVersionNumber with the versionNumber or wipVersionNumber from the subscription event, setting versionFilter.versionType to match which of the two you are passing—see Step 2.

    Step 4: Subscribe to Extraction Events for an Entire Project

    If your application monitors many models in the same project, use elementGroupExtractionStatusByProject instead of opening one subscription per file. Include the required Accept header from Step 1.

    1. Run the following cURL command, replacing {{YOUR_ACCESS_TOKEN}} and {{YOUR_ACC_PROJECT_ID}}.

      Subscription

      subscription elementGroupExtractionStatusByProject($input: ElementGroupExtractionByProjectInput!) {
          elementGroupExtractionStatusByProject(input: $input) {
              status
              details
              elementGroup {
                  id
                  name
                  alternativeIdentifiers {
                      fileUrn
                  }
                  version {
                      versionNumber
                      wipVersionNumber
                  }
              }
          }
      }
      
      Show More

      Request

      curl 'https://developer.api.autodesk.com/aec/beta/graphql' -v \
        -H 'accept: multipart/mixed;subscriptionSpec=1.0, application/json' \
        -H 'content-type: application/json' \
        -H 'Authorization: Bearer {{YOUR_ACCESS_TOKEN}}' \
        --data-raw '{
          "query": "subscription ($input: ElementGroupExtractionByProjectInput!) { elementGroupExtractionStatusByProject(input: $input) { status details elementGroup { id name alternativeIdentifiers { fileUrn } version { versionNumber wipVersionNumber } } } }",
          "variables": {
            "input": {
              "accProjectId": "{{YOUR_ACC_PROJECT_ID}}"
            }
          }
        }'
      
      Show More
    2. Keep the connection open and parse the multipart stream the same way as in Step 1. You receive an event each time any file in the project completes extraction.

      Use elementGroup.alternativeIdentifiers.fileUrn to identify which model triggered the event.

    Step 5: Production Considerations

    cURL is useful for testing subscriptions and understanding the multipart response format. For production applications, consider the following:

    Subscription connections can end

    Network timeouts, token expiry, or server-side limits can close the stream before an event arrives. Implement retry logic in your client:

    • Reconnect and resubscribe if the connection closes unexpectedly.
    • Use exponential backoff between retries.
    • Track the last known extraction state so you can fall back to elementGroupExtractionStatus if needed.

    A failed extraction produces no event

    The subscription only emits SUCCESS, so an extraction that failed is indistinguishable from one that is still running—in both cases nothing arrives on the stream. Do not treat silence as either success or failure:

    • Apply a timeout suited to your workflow, then query elementGroupExtractionStatus to get the actual status.
    • Use that query to tell IN_PROGRESS apart from FAILED, and to read details for a failed extraction.

    Use a GraphQL client with subscription support

    Most GraphQL HTTP clients handle queries and mutations only. For production, use a client library that supports GraphQL over HTTP subscriptions and multipart parsing, or implement multipart stream parsing in your application.

    Required headers for every subscription request

    Always send both of the following headers:

    • Authorization: Bearer {{YOUR_ACCESS_TOKEN}}
    • Accept: multipart/mixed;subscriptionSpec=1.0, application/json

    Comparison with polling


    ApproachWhen to useTrade-off
    elementGroupExtractionStatus query Simple one-off checks, fallback after a disconnect, or checking an extraction that produced no event Requires repeated polling until status changes; the only way to see IN_PROGRESS or FAILED
    Extraction status subscription Waiting for sync or publish extraction to finish Single long-lived connection; event-driven, but fires only on success—failures are silent