Getting Started with the T3 API¶
The T3 API is plain HTTP. This page walks through authenticating, finding your license, loading data, and writing to Metrc. The examples use Python's requests; any HTTP client works.
Note: most endpoints require a T3+ subscription. Basic plans with fewer than four seats can use the report endpoints only. A few endpoints, such as /v2/licenses, are free.
If you would rather not write code, Spreadsheet Sync loads a whole dataset into Excel or Google Sheets from a single URL.
1. Authenticate¶
Exchange your Metrc login for a token:
import requests
API = "https://api.trackandtrace.tools"
token = requests.post(
f"{API}/v2/auth/credentials",
json={
"hostname": "ca.metrc.com",
"username": "YOUR_METRC_USERNAME",
"password": "YOUR_METRC_PASSWORD",
},
).json()["accessToken"]
HEADERS = {"Authorization": f"Bearer {token}"}
For scripts that run unattended, use a secret key instead and send it as X-T3-API-Key. See Authentication for both formats.
2. Pick a license¶
Almost every endpoint needs a licenseNumber query parameter, and each request covers one license. List the licenses your login can reach:
licenses = requests.get(f"{API}/v2/licenses", headers=HEADERS).json()
for license in licenses:
print(license["licenseNumber"], license["licenseName"])
LICENSE = licenses[0]["licenseNumber"]
3. Load data¶
Collection endpoints return one page at a time:
page = requests.get(
f"{API}/v2/packages/active",
params={"licenseNumber": LICENSE, "pageSize": 100, "page": 1},
headers=HEADERS,
).json()
print(page["total"], "active packages")
for package in page["data"]:
print(package["label"], package["item"]["name"], package["quantity"])
{
"data": [ { "id": 12345, "label": "1A4FF0100000022000000123", "...": "..." } ],
"total": 1260,
"page": 1,
"pageSize": 100,
"totalPages": 13
}
pageSize goes up to 500 on most endpoints. Narrow a page with filter=field__operator:value and order it with sort=field:asc; the operators are listed in Shaping a Report.
From here:
- The whole dataset in one request: Reports.
- A record and its lab results, history or packages: Supercollections.
- One record by id: Loading One Record by ID.
- Find something without knowing where it is: Search.
Writing to Metrc¶
Every endpoint that changes Metrc data works the same way.
Writes are dry runs by default. T3 validates the payload and returns 200 without sending anything to Metrc. Add submit=true to actually write:
note = [{"id": 12345, "note": "Moved to vault"}]
# Dry run: checks the payload, writes nothing
requests.post(
f"{API}/v2/packages/notes",
params={"licenseNumber": LICENSE},
headers=HEADERS,
json=note,
).raise_for_status()
# Real write
requests.post(
f"{API}/v2/packages/notes",
params={"licenseNumber": LICENSE, "submit": "true"},
headers=HEADERS,
json=note,
).raise_for_status()
Add applyDynamicValidation=true to check against your live data. T3 then also confirms that the records your payload names exist and are eligible, and returns a 400 describing what is wrong instead of sending it. It is best-effort: a request that passes can still be refused by Metrc. To turn off one check while keeping the rest, add skipDynamicValidationChecks=CHECK_KEY; each endpoint's available keys are listed on its entry in the interactive docs.
Read the result back. Metrc sometimes answers 200 to a write it did not apply, so confirm the change with a read before relying on it. Each write page shows the read that verifies it.
Check permissions first. What your account may do varies by license, state and Metrc role. See Permissions.
The write guides:
- Plant Batches, Managing Plant Batches, Managing Plants
- Packages, Managing Packages, Retail ID Labels, Lab Testing
- Harvest Lifecycle
- Transfers, Layover Transfers, Receiving Transfers
Other ways to use the API¶
- Python libraries:
t3api-utilshandles authentication, license selection and loading every page for you. - AI tools: point a model at the API with AI & LLM Integration.
Postman¶
T3 has a public Postman workspace generated from the OpenAPI spec, along with an example Postman Flow that demonstrates authentication and reading data. See the OpenAPI Spec page for links and import instructions.
Next Steps¶
- Set up a Python environment and write API scripts.
- Browse every endpoint in the interactive API docs.
- Learn how to consume subsets of the OpenAPI spec.