# List test packages

`GET /v0/labs/testpackages`

> **Authentication:** every request must send `X-ConfidentLims-APIKey`, `X-ConfidentLims-Timestamp` (unix seconds) and `X-ConfidentLims-Signature`, an HMAC-SHA256 signature of the request. The examples below call `sign_request()` from the [Request Signing guide](https://api.confidentcannabis.com/v0/docs/request-signing.md) — read it first. Request bodies are form-encoded, never JSON.

Return every currently active test package offered by your lab, along with the
sample categories each package applies to and the test types it covers.

Use the `id` of a test package in `test_package_ids` when creating an order or
adding a sample to one.

## Parameters

No parameters.

## Responses

### 200 Success

Fields (alongside the `success: true` envelope flag):

- `test_packages` (array of objects)
  - `id` (integer) — Unique ID for Test Package
  - `name` (string) — Test Package Name
  - `price` (number) — Package Price - if 0, call for price
  - `minimum_quantity` (number) — Minimum sample quantity required for testing
  - `sample_categories` (array of objects)
    - `id` (integer) — Unique ID for Sample Category
    - `name` (string) — Sample Category Name
    - `industry_id` (integer) — Unique ID for Sample Industry
    - `industry_name` (string) — Sample Industry Name
  - `description` (string) — Test Package Description
  - `test_types` (array of objects)
    - `id` (integer) — Unique ID for Test Type
    - `name` (string) — Test Type Name
    - `abbreviation` (string) — Test Type Abbreviation
  - `compliance` (boolean) — Compliance Testing package

Example:

```json
{
  "success": true,
  "test_packages": [
    {
      "id": 4,
      "name": "California Compliance - Flower",
      "price": 275.0,
      "minimum_quantity": 5.0,
      "sample_categories": [
        {
          "id": 1,
          "name": "Plant",
          "industry_id": 1,
          "industry_name": "Cannabis & Hemp"
        }
      ],
      "description": "Full CA phase 3 compliance panel for flower and pre-rolls.",
      "test_types": [
        {
          "id": 1,
          "name": "Cannabinoids",
          "abbreviation": "CAN"
        },
        {
          "id": 5,
          "name": "Required Pesticides",
          "abbreviation": "PES-R"
        }
      ],
      "compliance": true
    },
    {
      "id": 9,
      "name": "Potency Only",
      "price": 65.0,
      "minimum_quantity": 3.0,
      "sample_categories": [
        {
          "id": 1,
          "name": "Plant",
          "industry_id": 1,
          "industry_name": "Cannabis & Hemp"
        }
      ],
      "description": "Cannabinoid potency by HPLC.",
      "test_types": [
        {
          "id": 1,
          "name": "Cannabinoids",
          "abbreviation": "CAN"
        }
      ],
      "compliance": false
    }
  ]
}
```

### 400 Bad request

The request was malformed or failed validation. Validation failures include per-field messages in `error_details`. Possible `error_code` values: `invalid_request`, `request_too_old`.

### 401 Unauthorized

Authentication failed. Possible `error_code` values: `missing_api_key`, `invalid_api_key`, `invalid_credentials_type`, `api_access_restricted`, `api_access_denied`, `missing_signature`, `missing_timestamp`, `invalid_timestamp`, `invalid_signature`.

### 403 Permission denied

The API key is valid but does not have permission for this endpoint (for example, a client key calling a labs endpoint). Possible `error_code` values: `permission_denied`.

## Examples

### cURL

```bash
# X-ConfidentLims-Signature: see the Request Signing guide - https://api.confidentcannabis.com/v0/docs/request-signing.md
curl -X GET 'https://api.confidentcannabis.com/v0/labs/testpackages' \
  -H 'X-ConfidentLims-APIKey: YOUR_API_KEY' \
  -H 'X-ConfidentLims-Timestamp: UNIX_TIMESTAMP' \
  -H 'X-ConfidentLims-Signature: REQUEST_SIGNATURE'
```

### Python

```python
import time
import requests

# sign_request() is defined in the Request Signing guide:
# https://api.confidentcannabis.com/v0/docs/request-signing.md
from sign_request import sign_request

API_KEY = 'YOUR_API_KEY'
API_SECRET = 'YOUR_API_SECRET'
path = '/v0/labs/testpackages'

headers = {'X-ConfidentLims-Timestamp': str(int(time.time()))}
headers['X-ConfidentLims-Signature'] = sign_request(
    'GET', path, headers, {}, API_KEY, API_SECRET)
headers['X-ConfidentLims-APIKey'] = API_KEY

response = requests.get(
    'https://api.confidentcannabis.com' + path,
    headers=headers,
)
print(response.json())
```

### JavaScript

```javascript
// signRequest() is defined in the Request Signing guide:
// https://api.confidentcannabis.com/v0/docs/request-signing.md
import { signRequest } from './sign_request.js';

const API_KEY = 'YOUR_API_KEY';
const API_SECRET = 'YOUR_API_SECRET';
const path = "/v0/labs/testpackages";

const headers = { 'X-ConfidentLims-Timestamp': String(Math.floor(Date.now() / 1000)) };
headers['X-ConfidentLims-Signature'] = signRequest(
  "GET", path, headers, {}, API_KEY, API_SECRET);
headers['X-ConfidentLims-APIKey'] = API_KEY;

const response = await fetch("https://api.confidentcannabis.com" + path, {
  headers,
});
console.log(await response.json());
```

---

HTML version: https://api.confidentcannabis.com/v0/docs/labs/get-test-packages  
OpenAPI spec for this section: https://api.confidentcannabis.com/v0/docs/labs/openapi.json  
Request Signing guide: https://api.confidentcannabis.com/v0/docs/request-signing.md
