> For the complete documentation index, see [llms.txt](https://help.bioinsight.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.bioinsight.illumina.com/clarity-lims/api-and-database/api-docs/tips-and-tricks/standardizing-sample-naming-via-the-api.md).

# Standardizing Sample Naming via the API

A lab may receive samples submitted from various sources. This can pose a problem with regards to sample names.There may be duplicate sample names, and/or various name formats, all of which make it hard for lab scientists to recognize a sample.

Clarity LIMS programmers often rename all incoming samples to a certain naming convention.

This section provides an example to address this problem.

### Recommendations <a href="#recommendations" id="recommendations"></a>

* When accepting a project and its samples, the receiving lab scientist runs a Clarity LIMS step named **Receive Samples**.
* The underlying **Receive Samples** process type / master step is configured with analyte (sample) inputs, and no analyte outputs.
* A shared result file output is configured to capture logging from the script.
* The sample name could be a derivative of the **Sample LIMSID**, with a prefix:
  * Because the LIMSID is guaranteed to be unique, this approach mitigates any need to maintain an external sequence of numbers.
  * The **Sample LIMSID** is derived from the **Project LIMSID**, which is configurable.

### Proposed solution

* The **Receive Samples** process is configured to trigger a script that renames the samples that are input to the process.
* This trigger also passes the **OriginatingProcessURI** to the script. This example assumes that the original submitted sample name must be preserved, and so it is saved in a sample UDF.

The following pseudo code shows how one might implement the sample-renaming script:

1. Connect to the API, using the **OriginatingProcessURI**.
2. Retrieve the **OriginatingProcessXML** and store it in a variable.
3. Iterate through the **inputoutput map** of the **OriginatingProcessXML**, and for each **InputArtifact**:
   * GET the **InputArtifactURI** and store the input **ArtifactXML** in a variable.
   * From this **ArtifactXML**, GET the **SourceSampleXML** and store it in another variable.
   * Modify the **SourceSampleXML**. To do this:
   * Rename the **SampleName** to a desired name (see Recommendations section, above).
   * Finally, PUT the **Sample XML** back.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.bioinsight.illumina.com/clarity-lims/api-and-database/api-docs/tips-and-tricks/standardizing-sample-naming-via-the-api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
