Import Guide
Use the Partner API to submit a file of products for import into your organization. This guide covers the POST /organizations/{organizationId}/imports endpoint. It also includes examples for planned purchase order and product assessment support.
The import endpoint is not yet released in Production.
Before you start
You need your Carbon Trail organization ID and an API key. Create an API key in the Carbon Trail Portal and include it in the Authorization header of each request. See Authentication for more details.
The API key needs write:imports to submit a file and read:imports to read import status and errors.
Set the following variables for the examples below:
export BASE_URL="https://api.carbontrail.net/partner/v1.0"
export ORGANIZATION_ID="YOUR_ORGANIZATION_ID"
export CARBON_TRAIL_API_KEY="ctk_v1_xxx"
For staging, set BASE_URL to https://staging.api.carbontrail.net/partner/v1.0 and use credentials for that environment. Keep your API key out of source control.
Prepare the file
The file field accepts a file in JSON Lines format: each line contains one complete JSON record. Use the .jsonl extension, or .jsonl.gz for a gzip-compressed file. For example, use products.jsonl or products.jsonl.gz.
The file must not be empty. The uploaded file must not exceed 250 MiB. For a gzip file, this limit applies to the compressed file size.
- Put each record on a separate line.
- Do not wrap the records in a JSON array or place commas between lines.
- Keep each record on one line rather than using multi-line, pretty-printed JSON.
Choose the recordType that matches the file:
| Records in the file | recordType | Support in the current code |
|---|---|---|
| Products | Product | Implemented |
| Purchase orders | Purchase Orders | Planned |
| Product assessments | Product Assessment | Planned |
Use these values exactly, including capitalization. Each file must contain a single record type. The current endpoint accepts only Product. Requests for Purchase Orders or Product Assessment return HTTP 400 with code UnsupportedRecordType. Their examples below describe planned support.
Choose the importType for the operation you want to perform:
| Operation | importType | Product behavior |
|---|---|---|
| Create records | Create | Create missing products. Skip existing products. |
| Create new records and update existing records | Create And Update | Create missing products. Apply a patch to existing products. |
| Update existing records | Update | Apply a patch to existing products. Skip missing products. |
Use these values exactly, including capitalization, and send importType as a multipart form field alongside recordType. The examples below use Create.
The processor matches existing products by SKU in the organization and subsidiary scope. Updates use the product patch rules. A skipped product is not counted as a failed record.
Example product file
Save the following as products.jsonl for recordType=Product. Each line represents a separate product:
Replace every YOUR_ORGANIZATION_ID value in the file, including the component product value, with the organization ID used in the request URL. The worker rejects a product if its organization or subsidiary ID does not match the request. This endpoint submits imports without a subsidiary ID, so omit subsidiaryId or set it to null.
{"productionTimestamp":"2026-05-05T12:00:28.071Z","category":"Apparel","type":"Shirt","name":"example T-Shirt","articleNumber":"T-Shirt 001","sku":"T-Shirt 001s","weightInGms":{"value":120},"organizationId":"YOUR_ORGANIZATION_ID","sizing":{"demographic":"Men","size":"S"},"components":[{"type":"Fabric","sku":"Fabric 001","amount":{"value":130},"unit":{"value":"Gram"},"componentProduct":{"category":"Fabric","type":"Fabric","name":"Fabric 001 Name","sku":"Fabric 001","materials":[{"name":"Cotton - Conventional","materialPercentageInComponent":65},{"name":"Polyester - Mix","materialPercentageInComponent":35}],"organizationId":"YOUR_ORGANIZATION_ID","amount":130,"unit":"Gram","fabricFormationType":{"value":"Woven"}}}],"manufacturingDetails":{"manufacturingLocation":{"value":{"country":"IN"}}}}
Example purchase order file (planned support)
This example is for planned support and cannot be imported through the current endpoint. Save it as purchase-orders.jsonl for recordType=Purchase Orders. Each line represents a separate purchase order record:
{"purchasedOrderNumber":"PO-001","sku":"ABC-001-BLK-M","articleNumber":"ABC-001","type":"T-shirts","supplierName":"Example Supplier","amount":100,"unit":"Unit"}
{"purchasedOrderNumber":"PO-002","sku":"ABC-001-BLK-L","articleNumber":"ABC-001","type":"T-shirts","supplierName":"Example Supplier","amount":200,"unit":"Unit"}
Example product assessment file (planned support)
This example is for planned support and cannot be imported through the current endpoint. Save it as product-assessments.jsonl for recordType=Product Assessment. This single record contains the product JSON and downstream details used for a cradle-to-grave LCA. Replace every YOUR_ORGANIZATION_ID value with your organization ID:
{"product":{"productionTimestamp":"2026-05-05T12:00:28.071Z","category":"Apparel","type":"Shirt","name":"example T-Shirt","articleNumber":"T-Shirt 001","sku":"T-Shirt 001s","weightInGms":{"value":120},"organizationId":"YOUR_ORGANIZATION_ID","sizing":{"demographic":"Men","size":"S"},"components":[{"type":"Fabric","sku":"Fabric 001","amount":{"value":130},"unit":{"value":"Gram"},"componentProduct":{"category":"Fabric","type":"Fabric","name":"Fabric 001 Name","sku":"Fabric 001","materials":[{"name":"Cotton - Conventional","materialPercentageInComponent":65},{"name":"Polyester - Mix","materialPercentageInComponent":35}],"organizationId":"YOUR_ORGANIZATION_ID","amount":130,"unit":"Gram","fabricFormationType":{"value":"Woven"}}}],"manufacturingDetails":{"manufacturingLocation":{"value":{"country":"IN"}}}},"distributionDetails":{"distributionLoss":0.02},"saleDetails":{"location":{"value":{"country":"IN"}}},"useDetails":{"numberOfWears":100,"washingFrequency":5,"minutesSpentIroning":3}}
These examples illustrate JSON Lines formatting using fields from the product, purchase order, and product assessment API models.
Submit a product import
Upload your prepared products.jsonl file using multipart/form-data:
curl --request POST \
"$BASE_URL/organizations/$ORGANIZATION_ID/imports" \
--header "Authorization: ApiKey $CARBON_TRAIL_API_KEY" \
--header "Accept: application/json" \
--form "file=@products.jsonl" \
--form "recordType=Product" \
--form "importType=Create"
The @ tells curl to upload the file's contents. Let curl set the Content-Type header so it includes the multipart boundary.
Submit a purchase order import (planned support)
When support is implemented, use Purchase Orders for a prepared purchase order file. The current endpoint rejects this request with UnsupportedRecordType:
curl --request POST \
"$BASE_URL/organizations/$ORGANIZATION_ID/imports" \
--header "Authorization: ApiKey $CARBON_TRAIL_API_KEY" \
--header "Accept: application/json" \
--form "file=@purchase-orders.jsonl" \
--form "recordType=Purchase Orders" \
--form "importType=Create"
Submit a product assessment import (planned support)
When support is implemented, use Product Assessment for a prepared product assessment file. The current endpoint rejects this request with UnsupportedRecordType:
curl --request POST \
"$BASE_URL/organizations/$ORGANIZATION_ID/imports" \
--header "Authorization: ApiKey $CARBON_TRAIL_API_KEY" \
--header "Accept: application/json" \
--form "file=@product-assessments.jsonl" \
--form "recordType=Product Assessment" \
--form "importType=Create"
Read the response
The endpoint returns HTTP 202 Accepted when an import is accepted. An illustrative response is:
{
"importId": "example-import-id",
"status": "Submitted",
"fileName": "products.jsonl"
}
| Field | Meaning |
|---|---|
importId | Identifier for tracking the import. |
status | Submitted when the job is created. |
fileName | Name of the uploaded file. |
A 202 response means the request was accepted for processing. It does not confirm that every record was imported successfully. The submission response does not include totalRecords, because the file records have not yet been counted.
Read import status
Use the importId from the submission response with the GET /organizations/{organizationId}/imports/{importId} endpoint:
export IMPORT_ID="example-import-id"
curl --request GET \
"$BASE_URL/organizations/$ORGANIZATION_ID/imports/$IMPORT_ID" \
--header "Authorization: ApiKey $CARBON_TRAIL_API_KEY" \
--header "Accept: application/json"
The endpoint returns HTTP 200 with the job status and record counts. For example, a completed import with some failed records can return:
{
"importId": "example-import-id",
"organizationId": "YOUR_ORGANIZATION_ID",
"status": "CompletedWithErrors",
"totalRecords": 100,
"createdRecords": 70,
"updatedRecords": 20,
"skippedRecords": 5,
"failedRecords": 5
}
| Field | Meaning |
|---|---|
importId | Identifier of the import job. |
organizationId | Organization that owns the import job. |
status | Current job status. See the table below. |
totalRecords | Total number of records in the import. |
createdRecords | Number of records successfully created. |
updatedRecords | Number of records successfully updated. |
skippedRecords | Number of records skipped under the selected import operation. |
failedRecords | Number of records that failed to process. |
New file imports start with Submitted. The API status values are:
| Status | Meaning | Next action |
|---|---|---|
Submitted | The job was submitted for processing. | Check status again later. |
Accepted | The job was accepted and is waiting for processing. | Check status again later. |
Processing | The job is being processed. | Check status again later. |
Completed | The job finished without failed records. Records can still have been skipped. | Stop checking status. |
CompletedWithErrors | The job finished with successful creates or updates and some failed records. | Stop checking status and read the import errors. |
Failed | The job failed. | Stop checking status and read any available errors. |
Repeat the status request while the job is Submitted, Accepted, or Processing. Record counts can remain zero until processing finishes. Use status to check completion, because zero counts do not mean that the import is complete.
The endpoint returns HTTP 404 with code NotFound if the import job is not found in the organization.
Read import errors
Use the importId from the submission response with the GET /organizations/{organizationId}/imports/{importId}/errors endpoint:
export IMPORT_ID="example-import-id"
curl --request GET \
"$BASE_URL/organizations/$ORGANIZATION_ID/imports/$IMPORT_ID/errors?page=1&pageSize=50" \
--header "Authorization: ApiKey $CARBON_TRAIL_API_KEY" \
--header "Accept: application/json"
The default page is 1. The default pageSize is 50. An example response is:
{
"data": [
{
"recordIndex": 0,
"message": "The product organization ID and subsidiary ID must match the corresponding IDs in the request.",
"code": "ProcessingError"
}
],
"page": 1,
"pageSize": 50,
"totalCount": 1
}
recordIndex starts at zero: 0 identifies the first record. Blank lines are not counted as records. data contains the errors for the requested page. totalCount is the total number of saved errors across all pages. An error can also include externalId when available.
Errors become available as processing continues. An empty data array does not confirm that the import is complete. Use the status endpoint above to check completion. The error endpoint returns HTTP 404 if the import job does not exist in the organization.