> ## Documentation Index
> Fetch the complete documentation index at: https://docs.junction.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Creating a Lab Test

> Create custom lab tests by selecting biomarker IDs and collection methods, then submit them for Junction approval before ordering.

Junction provides a way to create your own lab tests. A lab test is a collection or pre-set of orderable markers. These are made up of:

1. One or more marker IDs or Provider IDs.
2. The collection method: `testkit`, `walk_in_test`, `at_home_phlebotomy`, or `on_site_collection`.

Once a Lab Test is created and approved, you can use it when making an order.

<Warning>
  When you create a Lab Test, it is not immediately available. We need to validate and approve it on our side, before you can use it when making orders.
</Warning>

#### At-Home Phlebotomy Auto-Approval

<Card horizontal icon="person-digging" color="#57164A">
  This feature is in **closed beta**.

  Interested in this feature? Get in touch with your Customer Success Manager.
</Card>

For eligible teams and labs, Junction evaluates an `at_home_phlebotomy` lab test when it is created. The lab test is created with a status of `active` and can be ordered immediately when:

* Collection Instructions are available for every marker.
* Every marker is enabled for *à la carte* ordering, if your team does not use a delegated flow.
* The estimated draw is fewer than 15 tubes. An estimate of 15 tubes or more is rejected.

If an eligible at-home phlebotomy test does not meet one of these requirements, creation returns HTTP 400 and no lab test is created.

### Example

To begin, make a request to our [`GET /v3/lab_tests/markers`](/api-reference/lab-testing/biomarkers) endpoint, in order to choose the markers you want to test for.

```json Get all markers theme={null}
{
  "markers": [
    {
      "id": 1,
      "name": "17-OH Progesterone LCMS",
      "slug": "17-oh-progesterone-lcms",
      "description": "17-OH Progesterone LCMS",
      "lab_id": 1,
      "provider_id": "070085",
      "type": null,
      "unit": null,
      "price": "N/A"
    },
    {
      "id": 2,
      "name": "ABO Grouping",
      "slug": "abo-grouping",
      "description": "ABO Grouping",
      "lab_id": 1,
      "provider_id": "006056",
      "type": null,
      "unit": null,
      "price": "N/A"
    }
  ],
  "total": 2,
  "page": 1,
  "size": 2
}
```

With this information, you can create a lab test using [`POST /v3/lab_tests`](/api-reference/lab-testing/post-test).

As an example, let's say you wanted a test from `Labcorp`, with markers with provider IDs `006056` and `070085`:

```python Create a new test theme={null}
from junction import Junction, LabTestCollectionMethod
from junction.environment import JunctionEnvironment

client = Junction(
    api_key="YOUR_API_KEY",
    environment=JunctionEnvironment.SANDBOX,
)

data = client.lab_tests.create(
    name="Example test",
    description="Example test",
    method=LabTestCollectionMethod.AT_HOME_PHLEBOTOMY,
    provider_ids=["006056", "070085"],  # or use the marker ids e.g marker_ids=[1, 2]
)
```

<Note>
  It is possible to create a test with either the marker id or provider id. Provider ids are the recommended way, since these are shared across environments. Not all labs provide these, so in their absence, use the marker id.
</Note>

Once your lab test creation is successful you will receive the following response:

```json theme={null}
{
  "lab_test": {
    "name": "Example test",
    "description": "Example test",
    "sample_type": "serum",
    "method": "at_home_phlebotomy",
    "price": 10,
    "is_active": false,
    "status": "pending_approval",
    "lab": {
      "slug": "labcorp",
      "name": "LabCorp",
      "first_line_address": "123 Main St",
      "city": "San Francisco",
      "zipcode": "91789"
    },
    "markers": [
      {
        "name": "17-OH Progesterone LCMS",
        "slug": "17-oh-progesterone-lcms",
        "description": "17-OH Progesterone LCMS"
      },
      {
        "name": "ABO Grouping",
        "slug": "abo-grouping",
        "description": "ABO Grouping"
      }
    ]
  }
}
```

Note that `status` is set to `pending_approval`. You can verify when it changes to `active` by calling the [lab tests endpoint](/api-reference/lab-testing/tests-paginated). The `is_active` field is deprecated; use `status` instead.


## Related topics

- [Choosing Tests and Markers](/lab/workflow/ordering.md)
- [Testing in Sandbox](/lab/overview/sandbox.md)
- [Introduction](/lab/overview/introduction.md)
- [Get Lab Test](/api-reference/lab-testing/get-lab-test.md)
- [Get Markers for Lab Test](/api-reference/lab-testing/lab-test-markers.md)
