---
title: Run an IDS check via the API
summary: Validate an IDS and check one or more versions against it from JavaScript, Java, .NET or the OpenAPI, read the per-object results and the status per specification, and download them as BCF.
order: 10
languages: [javascript, java, csharp]
terms: [ids, check, bcf, version, vid, qid]
see-also: [how-to/using-bimworks/run-an-ids-check, explanation/checking-and-ids, how-to/checks]
notion: https://app.notion.com/p/181e41afde7f80b59187eba0408ca7fa
---

# Run an IDS check via the API

This guide runs an [[term:ids|IDS]] against model versions from code. The same check in the browser is [[page:how-to/using-bimworks/run-an-ids-check]].

## Before you start

You need the IDS as an XML string (IDS 1.0), the [[term:vid|Vids]] of processed versions, and a client with the `checks:run` scope. A check can take a while on large models: the JavaScript call waits up to ten minutes, the Java task and the .NET call up to an hour.

## Steps

1. **Run the check.** Pass the versions and the IDS; one call checks all of them together.

   ````code-group
   ```javascript
   const factory = new BimWorksClientFactory(BIM_WORKS_ADDRESS);
   const client = await factory.createClientWithApiToken(BIM_WORKS_API_TOKEN);

   const ids = await (await fetch("specification.ids")).text();
   const result = await client.checks.runIdsCheck([BIM_WORKS_FIRST_MODEL], ids);
   console.log(result.results.checkResults);
   ```
   ```java
   try (BimWorksClientFactory factory = new BimWorksClientFactory(BIM_WORKS_ADDRESS);
        BimWorksClient client = factory.createClientWithApiToken(BIM_WORKS_API_TOKEN)) {
   	String ids = Files.readString(Path.of("specification.ids"));
   	Set<UUID> versions = Set.of(UUID.fromString(BIM_WORKS_FIRST_MODEL));

   	ObjectNode result = client.modelChecks.runIdsCheck(ids, versions).executeAsync().get();
   	System.out.println(result.get("results").get("checkResults"));
   }
   ```
   ```csharp
   using (BimWorksClientFactory factory = new BimWorksClientFactory(new Uri(BIM_WORKS_ADDRESS)))
   using (BimWorksClient client = factory.CreateClientWithApiToken(BIM_WORKS_API_TOKEN))
   {
       string ids = File.ReadAllText("specification.ids");
       IdsCheckResult result = client.Checks.RunIdsCheck(Guid.Parse(BIM_WORKS_FIRST_MODEL), ids);
       Console.WriteLine(result.OverallResult);   // ERROR when any object fails
   }
   ```
   ```shell
   ADDRESS=BIM_WORKS_ADDRESS
   IDS=$(jq -Rs . < specification.ids)
   curl -s -X POST "$ADDRESS/openapi/ifc/Check" \
     -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
     -d '{"models": [{"type": "VersionModelIdentifier", "uuid": "'BIM_WORKS_FIRST_MODEL'"}], "ids": '"$IDS"'}'
   ```
   ````

2. **Read the result.** The response has two members:
   - `modelMapping` — the model UUID of each checked version, keyed by version UUID; results refer to objects by [[term:qid|Qid]].
   - `results.checkResults` — the result tree. Its `results` array holds one `ModelChecksContainer` per IDS specification (with the specification's name and description), and each container's `results` holds one `ObjectCheckResult` per applicable object with `checkResult` (`SUCCESS`, `ERROR`, `WARNING` or `INFO`), the object's `objectInfos[].qid` and the evaluation of every requirement. Each container also carries a `summary` with the counts per outcome. An entry's `type` field says which of the two it is.

   ```javascript {#walk}
   function failed(container, out = []) {
   	for (const entry of container.results) {
   		if (entry.type == "ModelChecksContainer") {
   			failed(entry, out);
   		} else if (entry.type == "ObjectCheckResult" && entry.checkResult == "ERROR") {
   			out.push(...entry.objectInfos.map((info) => info.qid));
   		}
   	}
   	return out;
   }
   const errorQids = failed(result.results.checkResults);
   ```

   The .NET SDK reads the tree for you: [[dotnet:BIM.works_SDK.IdsCheckResult|`IdsCheckResult`]] has the tree as [[dotnet:BIM.works_SDK.CheckResultNode|`CheckResultNode`]]s in [[dotnet:BIM.works_SDK.IdsCheckResult#Root|`Root`]], one container per specification in [[dotnet:BIM.works_SDK.IdsCheckResult#Specifications|`Specifications`]], and the object results in [[dotnet:BIM.works_SDK.IdsCheckResult#ObjectResults|`ObjectResults`]] and [[dotnet:BIM.works_SDK.IdsCheckResult#FailingObjectResults|`FailingObjectResults`]]. Each object result names its objects as [[dotnet:BIM.works_SDK.CheckedObject|`CheckedObject`]]s, with the Qid, name, GlobalId and IFC type.

   ```csharp {#walk-dotnet}
   List<string> errorQids = result.FailingObjectResults
       .SelectMany(node => node.Objects)
       .Select(o => o.Qid)
       .ToList();
   ```

3. **Or download the results as [[term:bcf|BCF]]**, one issue per failed object with a viewpoint, to hand to the modeller. The type is `"IdsCheck"` (`"Check3"` for a BCL definition).

   ````code-group
   ```javascript
   const url = await client.checks.downloadCheckResultsAsBcfDirect([BIM_WORKS_FIRST_MODEL], "IdsCheck", ids);
   window.open(url);   // a download URL for the .bcf file
   ```
   ```java
   DownloadCheckResultsAsBcfDirect download = client.modelChecks.downloadCheckResultsAsBcfDirect(versions, "IdsCheck", ids);
   download.executeAsync();
   try (OutputStream out = Files.newOutputStream(Path.of("results.bcf"))) {
   	download.downloadTo(out);
   }
   ```
   ```shell
   curl -s -X POST "$ADDRESS/openapi/ifc/Check" -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" -H "Accept: application/bcf" \
     -d '{"models": [{"type": "VersionModelIdentifier", "uuid": "'BIM_WORKS_FIRST_MODEL'"}], "ids": '"$IDS"'}' -o results.bcf
   ```
   ````

The OpenAPI operation is [[openapi:Check]]; it takes an `ids` or a `bcl` definition and returns JSON or, with `Accept: application/bcf`, the BCF archive. An IDS that is not valid XML is refused with [[error:INVALID_CHECK_DEFINITION]] (`400`) before any object is checked; an empty model set is allowed and validates the IDS without checking anything. Identical requests that arrive while the check runs share that run; nothing is stored, so a later call runs the check again.

`runIdsCheck` returns at most 200,000 object results (one per applicable object and specification; the server setting `checks.ids.legacy_max_object_results`). A larger result is refused with the error `RESULT_TOO_LARGE`, whose `payload` holds the counts per specification. To get only the counts, ask [[openapi:Check]] for `"format": "summary"`: it answers `summary`, the counts per outcome, without the object results.

```try-it
operation: Check
method: POST
path: /openapi/ifc/Check
body: |
  {
    "models": [{"type": "VersionModelIdentifier", "uuid": BIM_WORKS_FIRST_MODEL}],
    "ids": "<the IDS document as a string>",
    "format": "summary"
  }
```

The status of every IDS specification is not in that summary. The task `RunCheckSummary` with `models`, `input` (the IDS) and `specifications: true` adds it, through the SDKs' low-level client: `specifications` has one entry per IDS specification, in document order, with its `status` (`PASSED`, `FAILED`, `NOT_APPLICABLE` or `EVALUATION_ERROR`), `reason`, and the numbers of `applicable`, `passing` and `failing` objects.

In .NET that is [[dotnet:BIM.works_SDK.Checks#RunIdsCheckSummary|`client.Checks.RunIdsCheckSummary`]], which has no limit on the number of objects. It returns an [[dotnet:BIM.works_SDK.IdsCheckSummary|`IdsCheckSummary`]] with the counts and one [[dotnet:BIM.works_SDK.IdsSpecificationResult|`IdsSpecificationResult`]] per specification, each with its requirements' counts. When `RunIdsCheck` is refused with `RESULT_TOO_LARGE`, [[dotnet:BIM.works_SDK.Checks#ReadTooLargeSummary|`Checks.ReadTooLargeSummary(e)`]] reads the same summary from the refusal.

```csharp {#summary-dotnet}
IdsCheckSummary summary = client.Checks.RunIdsCheckSummary(Guid.Parse(BIM_WORKS_FIRST_MODEL), ids);
foreach (IdsSpecificationResult specification in summary.Specifications)
{
    Console.WriteLine($"{specification.Name}: {specification.Status}, {specification.Failing} of {specification.Applicable} failing");
}
```

## Validate an IDS without running it {#validate}

The task `ValidateAction` with `main_type: "IDS"` and `input` (the IDS) checks that the IDS is well-formed XML and valid against the IDS 1.0 schema, without a model. It answers `null` for a valid IDS and refuses an invalid one with `VALIDATION_EXCEPTION`, whose message names the line and the element. Entity names are not looked up: an entity that is no IFC class applies to no object when the IDS runs. Regular expressions are checked when the IDS runs: an invalid pattern gives an `ERROR` result titled "IDS validation error" in the run's results.

In .NET, [[dotnet:BIM.works_SDK.Checks#ValidateIds|`client.Checks.ValidateIds`]] returns an [[dotnet:BIM.works_SDK.IdsValidationResult|`IdsValidationResult`]]. An invalid IDS is an answer, not an exception; other refusals (no login, a missing scope) still throw [[dotnet:BIM.works_SDK.BimWorksException|`BimWorksException`]].

```csharp {#validate-dotnet}
IdsValidationResult validation = client.Checks.ValidateIds(ids);
if (!validation.IsValid)
{
    Console.WriteLine(validation.Message);   // e.g. cvc-complex-type.2.4.a: Invalid content was found starting with element ...
}
```

## Check

Colour the failed objects red in a viewer: `objectStateManager.changeColor(errorQids, "#EC4339")` marks exactly the objects the BIM.works UI lists under the specification with *Show only errors*.
