Entity Reference Import Guide
Use EntityReference when an API field needs to identify a record that already exists in your Carbon Trail organization. A reference lets you supply a Carbon Trail ID, an alias, or an identifier from another system. The API resolves the reference to the existing record; the reference does not create one.
The Purchase Order API and the Product API accept EntityReference to identify existing suppliers and supplier facilities.
What is an EntityReference?
An EntityReference is an object that identifies an existing record by at least one of these fields:
| Field | Type | Meaning |
|---|---|---|
id | string | The existing record's Carbon Trail ID. |
alias | object | An alternative identifier associated with the record. Its fields are id (the Carbon Trail ID of the alias definition), name (the alias name), and value (the identifier assigned to the record). |
externalIdentities | array of objects | Identifiers from well know external systems such as Higg, Open Supply Hub etc. Each object has name (the source system, such as Higg Id, Open Supply Hub Id) and value (the identifier in that system). If you provide multiple pairs, they must all match the same record. |
Set at least one of id, alias, or externalIdentities in each reference. Use values already associated with the record you want to identify. The receiving API field determines the type of record: for example, supplierReference identifies a supplier, while supplierFacilityReference identifies a supplier facility.
By Carbon Trail ID
{ "id": "supplier-123" }
By alias
Carbon Trail automatically creates two special aliases for your organization so you can provide your internal supplier and facility IDs. Their alias definition IDs are reserved: use DI2AQRI8m7uilnM-WeuYn in alias.id for a supplier and EbkGLVRWCHO-bCCrdHffw for a supplier facility. These IDs are fixed values, not placeholders. Put the internal ID already associated with the record in alias.value:
{
"supplierReference": {
"alias": { "id": "DI2AQRI8m7uilnM-WeuYn", "value": "SUP-001" }
},
"supplierFacilityReference": {
"alias": { "id": "EbkGLVRWCHO-bCCrdHffw", "value": "FAC-002" }
}
}
For any other alias, get its definition ID for alias.id from the alias definitions API.
By external identity
{
"externalIdentities": [{ "name": "Higg Id", "value": "VENDOR-001" }]
}
externalIdentities is a separate way to reference a record; its entries use a source system name and value, not an alias definition ID. It is an array even when you supply only one identifier. For a reference with several entries, every name and value pair must belong to the same record.
Use a reference in an API request
Purchase orders
Place the reference object in an API field that accepts EntityReference. For example, the create purchase order API accepts references for both the supplier and its facility. This request identifies both by their external ID aliases:
curl --request POST \
"https://api.carbontrail.net/partner/v1.0/organizations/YOUR_ORGANIZATION_ID/purchase-orders" \
--header "Authorization: ApiKey YOUR_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"category": "Purchased Goods",
"purchasedOrderNumber": "PO-001",
"type": "T-shirts",
"amount": 100,
"unit": "Unit",
"supplierReference": {
"alias": { "id": "DI2AQRI8m7uilnM-WeuYn", "value": "SUP-001" }
},
"supplierFacilityReference": {
"alias": { "id": "EbkGLVRWCHO-bCCrdHffw", "value": "FAC-002" }
}
}'
Replace the example organization ID, API key, and identifiers with values from your organization. The API key setup is described in Authentication.
The batch purchase order API accepts the same reference fields on each purchase order in its activities array. For JSON Lines file uploads, see the Import Guide for the file format and import endpoint.
Products
You can send supplier and supplier facility references when you create or replace a product. You can also send these references in the product object when you create a product assessment. See Create a product, Replace a product, and Create a product assessment.
| Location in the product | Supplier field | Supplier facility field |
|---|---|---|
materials[] | supplierReference.value | supplierFacilityReferences.value (array) |
manufacturingDetails | supplierReference.value | supplierFacilityReference.value |
manufacturingDetails.processes[] | supplierReference.value | supplierFacilityReference.value |
accessories[].value | supplierReference | — |
packaging.materials[].value | supplierReference.value | — |
The same fields apply to nested products in components[].componentProduct.
This part of a product request shows how to identify a material supplier and two supplier facilities by alias.
{
"materials": [
{
"name": "Cotton",
"supplierReference": {
"value": {
"alias": { "id": "DI2AQRI8m7uilnM-WeuYn", "value": "SUP-001" }
}
},
"supplierFacilityReferences": {
"value": [
{ "alias": { "id": "EbkGLVRWCHO-bCCrdHffw", "value": "FAC-002" } },
{ "alias": { "id": "EbkGLVRWCHO-bCCrdHffw", "value": "FAC-003" } }
]
}
}
]
}