# Apply Reagent Labels with REST

Reagent labels are artifact resource elements and can be applied using a PUT. To apply a reagent label to an artifact using REST, the following steps are required:

1. GET the artifact representation.
2. Insert a reagent-label element with the intended label name.
3. PUT the modified artifact representation back.

You can apply the reagent label to the original analyte (sample) artifact or to a downstream sample or result file.

### Prerequisites

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

* Reagent types that are configured in Clarity LIMS and are named index 1 through index 6.
* Reagents of type index 1 through index 6 that have been added to Clarity LIMS.
* A compatible version of API (v2 r14 to v2 r24).

### Code Example <a href="#example" id="example"></a>

In this example, you can adjust the following code:

```
def toLabel = GLSRestApiUtils.httpGET(artifactToLabelURI, username, password)
println '*** Before labeling'
println GLSRestApiUtils.nodeToXmlString(toLabel)
println
 
new Node(toLabel, 'reagent-label', [name: 'Index 1'])
println '*** After labeling'
println GLSRestApiUtils.nodeToXmlString(toLabel)
println
 
GLSRestApiUtils.httpPUT(toLabel, toLabel.@uri, username, password)
```

By inserting the reagent-label element, you end up with the following code.

<pre><code>*** Before labeling
&#x3C;?xml version="1.0" encoding="UTF-8" standalone="yes"?>
&#x3C;art:artifact xmlns:udf="http://genologics.com/ri/userdefined"
    xmlns:file="http://genologics.com/ri/file" xmlns:art="http://genologics.com/ri/artifact"
    uri="http://yourIPaddress/api/v2/artifacts/RCY1A97PA1?state=301" limsid="RCY1A97PA1">
    &#x3C;name>Sample-1&#x3C;/name>
    &#x3C;type>Analyte&#x3C;/type>
    &#x3C;output-type>Analyte&#x3C;/output-type>
    &#x3C;qc-flag>UNKNOWN&#x3C;/qc-flag>
    &#x3C;location>
        &#x3C;container uri="http://yourIPaddress/api/v2/containers/27-12" limsid="27-12" />
        &#x3C;value>A:1&#x3C;/value>
    &#x3C;/location>
    &#x3C;working-flag>true&#x3C;/working-flag>
    &#x3C;sample uri="http://yourIPaddress/api/v2/samples/RCY1A97" limsid="RCY1A97" />
&#x3C;/art:artifact>
 
*** After labeling
&#x3C;?xml version="1.0" encoding="UTF-8" standalone="yes"?>
&#x3C;art:artifact xmlns:udf="http://genologics.com/ri/userdefined"
    xmlns:file="http://genologics.com/ri/file" xmlns:art="http://genologics.com/ri/artifact"
    uri="http://yourIPaddress/api/v2/artifacts/RCY1A97PA1?state=301" limsid="RCY1A97PA1">
    &#x3C;name>Sample-1&#x3C;/name>
    &#x3C;type>Analyte&#x3C;/type>
    &#x3C;output-type>Analyte&#x3C;/output-type>
    &#x3C;qc-flag>UNKNOWN&#x3C;/qc-flag>
    &#x3C;location>
        &#x3C;container uri="http://yourIPaddress/api/v2/containers/27-12" limsid="27-12" />
        &#x3C;value>A:1&#x3C;/value>
    &#x3C;/location>
    &#x3C;working-flag>true&#x3C;/working-flag>
    &#x3C;sample uri="http://yourIPaddress/api/v2/samples/RCY1A97" limsid="RCY1A97" />
<strong>    &#x3C;reagent-label name="Index 1" />
</strong>&#x3C;/art:artifact>
</code></pre>

Although it is not mandatory, it is recommended that you name reagent labels after reagent types using the Index special type. This allows you to relate the reagent label back to its sequence.


---

# Agent Instructions: 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:

```
GET https://help.connected.illumina.com/clarity-lims/api-and-database/api-docs/cookbook/work-with-multiplexing/apply-reagent-labels-with-rest.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
