---
title: ActionsApi
summary: .NET SDK: the Actions operations, 6 methods, each with its parameters, result and a complete example.
order: 10
languages: [csharp]
sdk-package: .NET SDK · BIMworks.Sdk
link-terms: true
---

# ActionsApi

[[page:reference/sdk/dotnet|.NET SDK]] · `BIMworks.Sdk.Api` · class · 6 methods

Stored queries, checks, visualizations and other actions, which Query and Check run by uuid

Construct it with the client of [[page:reference/sdk/dotnet#connect|the connect step]]: `client.GetRequiredService<IActionsApi>()`. Each method is one operation of the [[page:api|API part]], where it runs on its page.

<table class="dense">
<thead><tr><th>Method</th><th>Operation</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>[[page:reference/sdk/dotnet/actionsapi#addaction|AddActionAsync]]</code></td><td>[[openapi:AddAction]]</td><td>Store an action</td></tr>
<tr><td><code>[[page:reference/sdk/dotnet/actionsapi#deleteaction|DeleteActionAsync]]</code></td><td>[[openapi:DeleteAction]]</td><td>Delete an action</td></tr>
<tr><td><code>[[page:reference/sdk/dotnet/actionsapi#getaction|GetActionAsync]]</code></td><td>[[openapi:GetAction]]</td><td>Read an action</td></tr>
<tr><td><code>[[page:reference/sdk/dotnet/actionsapi#listactions|ListActionsAsync]]</code></td><td>[[openapi:ListActions]]</td><td>List the actions in a folder</td></tr>
<tr><td><code>[[page:reference/sdk/dotnet/actionsapi#undeleteaction|UndeleteActionAsync]]</code></td><td>[[openapi:UndeleteAction]]</td><td>Bring back a deleted action</td></tr>
<tr><td><code>[[page:reference/sdk/dotnet/actionsapi#updateaction|UpdateActionAsync]]</code></td><td>[[openapi:UpdateAction]]</td><td>Change an action</td></tr>
</tbody>
</table>

## `AddActionAsync` {#addaction}

```csharp
Task<IAddActionApiResponse> AddActionAsync(AddActionRequest addActionRequest, CancellationToken cancellationToken = default)
```

Store an action. Stores a query, check, visualization or other action in a folder, or a new folder (`main_type: FOLDER`). Needs write rights on the folder.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:AddAction]] · <code>POST /openapi/actions/AddAction</code></td></tr>
<tr><th>Scope</th><td>[[scope:actions:write]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>addActionRequest</code></td><td><code>[[page:reference/sdk/dotnet/models#AddActionRequest|AddActionRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:AddAction]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>[[page:reference/sdk/dotnet/models#BimAction|BimAction]]</code> — The stored action

### Example

```csharp
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("BIM_WORKS_ADDRESS" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("BIM_WORKS_API_TOKEN"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<AddActionRequest>("""
    {
      "parent_uuid": "5e4d3c2b-1a09-4f8e-9d7c-6b5a49382716",
      "name": "External walls",
      "main_type": "QUERY3",
      "query": "GET attribute.Name WHERE type = IFCWALL AND property.Pset_WallCommon.IsExternal = true"
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IActionsApi>().AddActionAsync(request);

// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));
```

## `DeleteActionAsync` {#deleteaction}

```csharp
Task<IDeleteActionApiResponse> DeleteActionAsync(DeleteActionRequest deleteActionRequest, CancellationToken cancellationToken = default)
```

Delete an action. Moves the action to the deleted ones (ListActions show_deleted); UndeleteAction brings it back.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:DeleteAction]] · <code>POST /openapi/actions/DeleteAction</code></td></tr>
<tr><th>Scope</th><td>[[scope:actions:write]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>deleteActionRequest</code></td><td><code>[[page:reference/sdk/dotnet/models#DeleteActionRequest|DeleteActionRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:DeleteAction]]'s request body.</td></tr>
</tbody>
</table>

### Returns

Nothing: the operation answers without a body (Deleted).

### Example

```csharp
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("BIM_WORKS_ADDRESS" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("BIM_WORKS_API_TOKEN"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<DeleteActionRequest>("""
    {
      "uuid": "BIM_WORKS_FIRST_MODEL"
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IActionsApi>().DeleteActionAsync(request);

// 4. The result
// (DeleteAction answers no content: the call returns once it succeeded and throws an HttpRequestException otherwise)
if (!response.IsSuccessStatusCode) throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine("Done");
```

## `GetActionAsync` {#getaction}

```csharp
Task<IGetActionApiResponse> GetActionAsync(Option<GetActionRequest> getActionRequest = default, CancellationToken cancellationToken = default)
```

Read an action. One action with its text, by `uuid` or by `path` (from the caller's own folder).

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:GetAction]] · <code>POST /openapi/actions/GetAction</code></td></tr>
<tr><th>Scope</th><td>[[scope:actions:read]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>getActionRequest</code></td><td><code>[[page:reference/sdk/dotnet/models#GetActionRequest|GetActionRequest]]</code><span class="opt">optional</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:GetAction]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>[[page:reference/sdk/dotnet/models#BimAction|BimAction]]</code> — The action

### Example

```csharp
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("BIM_WORKS_ADDRESS" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("BIM_WORKS_API_TOKEN"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<GetActionRequest>("""
    {
      "uuid": "BIM_WORKS_FIRST_MODEL",
      "path": ""
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IActionsApi>().GetActionAsync(request);

// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));
```

## `ListActionsAsync` {#listactions}

```csharp
Task<IListActionsApiResponse> ListActionsAsync(Option<ListActionsRequest> listActionsRequest = default, CancellationToken cancellationToken = default)
```

List the actions in a folder. The stored actions (queries, checks, visualizations, ...) and folders in a folder, by name, and the folder's path. The folder by `uuid` or by `path` (from the caller's own folder); the caller's own folder when both are absent. Query and Check run a stored action by its uuid (`action_uuid`).

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:ListActions]] · <code>POST /openapi/actions/ListActions</code></td></tr>
<tr><th>Scope</th><td>[[scope:actions:read]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>listActionsRequest</code></td><td><code>[[page:reference/sdk/dotnet/models#ListActionsRequest|ListActionsRequest]]</code><span class="opt">optional</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:ListActions]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>[[page:reference/sdk/dotnet/models#ActionList|ActionList]]</code> — The folder's content

### Example

```csharp
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("BIM_WORKS_ADDRESS" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("BIM_WORKS_API_TOKEN"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<ListActionsRequest>("""
    {
      "uuid": "BIM_WORKS_FIRST_MODEL",
      "path": "",
      "show_deleted": false
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IActionsApi>().ListActionsAsync(request);

// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));
```

## `UndeleteActionAsync` {#undeleteaction}

```csharp
Task<IUndeleteActionApiResponse> UndeleteActionAsync(UndeleteActionRequest undeleteActionRequest, CancellationToken cancellationToken = default)
```

Bring back a deleted action. Undoes DeleteAction.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:UndeleteAction]] · <code>POST /openapi/actions/UndeleteAction</code></td></tr>
<tr><th>Scope</th><td>[[scope:actions:write]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>undeleteActionRequest</code></td><td><code>[[page:reference/sdk/dotnet/models#UndeleteActionRequest|UndeleteActionRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:UndeleteAction]]'s request body.</td></tr>
</tbody>
</table>

### Returns

Nothing: the operation answers without a body (Restored).

### Example

```csharp
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("BIM_WORKS_ADDRESS" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("BIM_WORKS_API_TOKEN"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<UndeleteActionRequest>("""
    {
      "uuid": "BIM_WORKS_FIRST_MODEL"
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IActionsApi>().UndeleteActionAsync(request);

// 4. The result
// (UndeleteAction answers no content: the call returns once it succeeded and throws an HttpRequestException otherwise)
if (!response.IsSuccessStatusCode) throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine("Done");
```

## `UpdateActionAsync` {#updateaction}

```csharp
Task<IUpdateActionApiResponse> UpdateActionAsync(UpdateActionRequest updateActionRequest, CancellationToken cancellationToken = default)
```

Change an action. Changes the fields that are passed; the others stay as they are. A change to an action (not a folder) is a new version unless `save_mode` is OVERWRITE. Pass `base_version`, the version you started from, to have a change by someone else in between refused with 409 instead of overwritten. A folder takes only a new `name`.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:UpdateAction]] · <code>POST /openapi/actions/UpdateAction</code></td></tr>
<tr><th>Scope</th><td>[[scope:actions:write]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>updateActionRequest</code></td><td><code>[[page:reference/sdk/dotnet/models#UpdateActionRequest|UpdateActionRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:UpdateAction]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>[[page:reference/sdk/dotnet/models#BimAction|BimAction]]</code> — The action as it is now

### Example

```csharp
using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;

// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
    var services = new ServiceCollection();
    services.AddApi(options =>
    {
        options.AddTokens(new BearerToken(bearer));
        options.AddApiHttpClients(http =>
        {
            http.BaseAddress = new Uri("BIM_WORKS_ADDRESS" + "/openapi");
            http.Timeout = Timeout.InfiniteTimeSpan;
        });
    });
    return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("BIM_WORKS_API_TOKEN"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;

// 2. The request
var request = JsonSerializer.Deserialize<UpdateActionRequest>("""
    {
      "uuid": "BIM_WORKS_FIRST_MODEL",
      "name": "",
      "query": "",
      "description": "",
      "output_hint": "VIEWER_3D",
      "favourite": false,
      "save_mode": "NEW_VERSION",
      "save_comment": "",
      "base_version": 0
    }
    """, json);

// 3. The call
var response = await client.GetRequiredService<IActionsApi>().UpdateActionAsync(request);

// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));
```
