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, or 50 on supercollections. Narrow a page with filter=field__operator:value and order it with sort=field:asc; the operators are listed in Shaping a Report, and the fields each collection can be filtered on in Filterable Fields.
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()
A write answers 201 when it makes new records, such as packages, plants, plant batches, harvests, items, strains or transfers, and 200 otherwise. A dry run always answers 200. Treat any 2xx as success, as raise_for_status() does. The errors:
400: refused, with the reason indetail. Nothing was written.401: sign in again.403: the Metrc account doesn't have permission for this on the license.429: too many requests. Wait, then send it again.502or504: Metrc failed or didn't answer in time. The write may have landed, so read it back before sending it again.
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.
Add applyDynamicConfirmation=true to have T3 confirm the outcome. The status then says whether the write succeeded: 200, or 201 for a create, if it did, and 400 with the code METRC_WRITE_FAILED if it failed. A 502 or 504 still means T3 isn't sure, so check Metrc before sending it again. A create also lists what it made under created, with the ids Metrc's own answer leaves out. Each endpoint's entry in the interactive docs says whether it can confirm; one that can't answers 400 and sends nothing.
response = requests.post(
f"{API}/v2/packages/finish",
params={"licenseNumber": LICENSE, "submit": "true", "applyDynamicConfirmation": "true"},
headers=HEADERS,
json=[{"id": 12345, "actualDate": "2026-12-01"}],
)
response.raise_for_status() # a 400 METRC_WRITE_FAILED means nothing was applied
Otherwise, 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 library:
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.
- Example script:
getting-started/intro.py(log in, list your licenses, export active packages). - Browse every endpoint in the interactive API docs.
- Learn how to consume subsets of the OpenAPI spec.