> For the complete documentation index, see [llms.txt](https://help.claritylims.illumina.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.claritylims.illumina.com/api-and-database/api-docs/cookbook/work-with-batch-resources/introduction-to-batch-resources.md).

# Introduction to Batch Resources

The powerful batch resources included in the Clarity LIMS Rapid Scripting API significantly increase the speed of script execution by allowing batch operations on samples and containers. These resources are useful when working with multiple samples and containers in high throughput labs.

The following simple example uses batch resources to move samples from one workflow queue into another queue.

It is useful to review the [Work with Batch Resources](/api-and-database/api-docs/cookbook/work-with-batch-resources.md).

Use a batch retrieve request to find all the artifacts in an artifact group, and then use a batch update request to move those artifacts into another artifact group.

The following steps are required:

1. Find all the artifacts that are in a particular artifact group.
2. Use the artifacts.batch.retrieve (list) resource to retrieve the details for all the artifacts.
3. Use the artifacts.batch.update (list) resource to update the artifacts and move them into a different artifact group, posting them back as a batch.

**NOTE**: The only HTTP method for batch resources is POST.

### Prerequisites

Before you follow the steps, make sure that you have the following items:

* Clarity LIMS contains a collection of samples (artifacts) residing in the same workflow queue (artifact group)
* A second queue exists into which you can move the collection of samples
* A compatible version of API (v2 r21 and later).

{% hint style="info" %}
In the REST API, artifacts are grouped with the artifact group resource. In Clarity LIMS, an artifact group is displayed as a workflow. Workflows are configured as queues, allowing lab scientists to locate samples to work with on the bench quickly.
{% endhint %}

### Step 1. Find All of the Samples in a Workflow Queue <a href="#step1" id="step1"></a>

To find the samples (artifacts) in a workflow queue (artifact group), use the following request, editing the server details and artifact group name to match those in your system:

```
http://your-server-ip/api/v2/artifacts?artifactgroup=my_queue
```

This request returns a list of URI links for all artifacts in the artifact group specified. In our example, the **my\_queue** queue contains three artifacts:

```
<art:artifacts xmlns:art="http://genologics.com/ri/artifact">
  <artifact limsid="ADM1A1PA1" uri="http://your-server-ip/api/v2/artifacts/ADM1A1PA1"/>
  <artifact limsid="ADM1A2PA1" uri="http://your-server-ip/api/v2/artifacts/ADM1A2PA1"/>
  <artifact limsid="ADM1A3PA1" uri="http://your-server-ip/api/v2/artifacts/ADM1A3PA1"/>
</art:artifacts>
```

### Step 2. Retrieve Sample Details <a href="#step2" id="step2"></a>

To retrieve the detailed XML for all of the artifacts, use a **\<links>** tag to post the set of URI links to the server using a batch retrieve request:

```
<ri:links xmlns:ri="http://genologics.com/ri">
  <link uri="http://your-server-ip/api/v2/artifacts/ADM1A1PA1" rel="artifacts"/>
  <link uri="http://your-server-ip/api/v2/artifacts/ADM1A2PA1" rel="artifacts"/>
  <link uri="http://your-server-ip/api/v2/artifacts/ADM1A3PA1" rel="artifacts"/>
</ri:links>
```

```
http://your-server-ip/api/v2/artifacts/batch/retrieve
```

This returns the detailed XML for each of the artifacts in the batch:

```
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<art:details xmlns:udf="http://genologics.com/ri/userdefined" 
xmlns:file="http://genologics.com/ri/file" xmlns:art="http://genologics.com/ri/artifact">
  <art:artifact uri="http://your-server-ip/api/v2/artifacts/ADM1A1PA1?state=21" limsid="ADM1A1PA1">
    <name>base-1</name>
    <type>Analyte</type>
    <output-type>Analyte</output-type>
    <qc-flag>UNKNOWN</qc-flag>
    <location>
      <container uri="http://your-server-ip/api/v2/containers/27-10" limsid="27-10"/>
      <value>1:1</value>
    </location>
    <working-flag>true</working-flag>
    <sample uri="http://your-server-ip/api/v2/samples/ADM1A1" limsid="ADM1A1"/>
    <artifact-group name="my_queue" uri="http://your-server-ip/api/v2/artifactgroups/1"/>
  </art:artifact>
  <art:artifact uri="http://your-server-ip/api/v2/artifacts/ADM1A2PA1?state=42" limsid="ADM1A2PA1">
    <name>base-2</name>
    <type>Analyte</type>
    <output-type>Analyte</output-type>
    <qc-flag>UNKNOWN</qc-flag>
    <location>
      <container uri="http://your-server-ip/api/v2/containers/27-11" limsid="27-11"/>
      <value>1:1</value>
    </location>
    <working-flag>true</working-flag>
    <sample uri="http://your-server-ip/api/v2/samples/ADM1A2" limsid="ADM1A2"/>
    <artifact-group name="my_queue" uri="http://your-server-ip/api/v2/artifactgroups/1"/>
  </art:artifact>
  <art:artifact uri="http://your-server-ip/api/v2/artifacts/ADM1A3PA1?state=12" limsid="ADM1A3PA1">
    <name>base-3</name>
    <type>Analyte</type>
    <output-type>Analyte</output-type>
    <qc-flag>UNKNOWN</qc-flag>
    <location>
      <container uri="http://your-server-ip/api/v2/containers/27-12" limsid="27-12"/>
      <value>1:1</value>
    </location>
    <working-flag>true</working-flag>
    <sample uri="http://your-server-ip/api/v2/samples/ADM1A3" limsid="ADM1A3"/>
    <artifact-group name="my_queue" uri="http://your-server-ip/api/v2/artifactgroups/1"/>
  </art:artifact>
</art:details>
```

The XML returned includes the artifact group name and URI:

**\<artifact-group name="my\_queue" uri="[http://your-server-ip/api/v2/artifactgroups/1"/>](http://your-server-ip/api/v2/artifactgroups/1"/>)**

### Step 3. Move All Samples into a Different Queue <a href="#step3" id="step3"></a>

To move the artifacts into another queue, simply update the **artifact-group name** and URI values:

```
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<art:details xmlns:udf="http://genologics.com/ri/userdefined" xmlns:file="http://genologics.com/ri/file" xmlns:art="http://genologics.com/ri/artifact">
  <art:artifact uri="http://your-server-ip/api/v2/artifacts/ADM1A1PA1?state=21" limsid="ADM1A1PA1">
    <name>base-1</name>
    <type>Analyte</type>
    <output-type>Analyte</output-type>
    <qc-flag>UNKNOWN</qc-flag>
    <location>
      <container uri="http://your-server-ip/api/v2/containers/27-10" limsid="27-10"/>
      <value>1:1</value>
    </location>
    <working-flag>true</working-flag>
    <sample uri="http://your-server-ip/api/v2/samples/ADM1A1" limsid="ADM1A1"/>
    <artifact-group name="new_queue"  uri="http://your-server-ip/api/v2/artifactgroups/2"/>
  </art:artifact>
  <art:artifact uri="http://your-server-ip/api/v2/artifacts/ADM1A2PA1?state=42" limsid="ADM1A2PA1">
    <name>base-2</name>
    <type>Analyte</type>
    <output-type>Analyte</output-type>
    <qc-flag>UNKNOWN</qc-flag>
    <location>
      <container uri="http://your-server-ip/api/v2/containers/27-11" limsid="27-11"/>
      <value>1:1</value>
    </location>
    <working-flag>true</working-flag>
    <sample uri="http://your-server-ip/api/v2/samples/ADM1A2" limsid="ADM1A2"/>
    <artifact-group name="new_queue"  uri="http://your-server-ip/api/v2/artifactgroups/2"/>
  </art:artifact>
  <art:artifact uri="http://your-server-ip/api/v2/artifacts/ADM1A3PA1?state=12" limsid="ADM1A3PA1">
    <name>base-3</name>
    <type>Analyte</type>
    <output-type>Analyte</output-type>
    <qc-flag>UNKNOWN</qc-flag>
    <location>
      <container uri="http://your-server-ip/api/v2/containers/27-12" limsid="27-12"/>
      <value>1:1</value>
    </location>
    <working-flag>true</working-flag>
    <sample uri="http://your-server-ip/api/v2/samples/ADM1A3" limsid="ADM1A3"/>
    <artifact-group name="new_queue"  uri="http://your-server-ip/api/v2/artifactgroups/2"/>
  </art:artifact>
</art:details>
```

Finally, post the XML back to the server using a batch update request:

```
http://your-server-ip/api/v2/artifacts/batch/update
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.claritylims.illumina.com/api-and-database/api-docs/cookbook/work-with-batch-resources/introduction-to-batch-resources.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
