Python SDK Examples

End-to-end examples for the planned ConformaESG Python SDK.

All examples use placeholders. Load CONFORMA_API_KEY from a secret manager or environment variable.

Supplier sync and certification file

Python
from pathlib import Path
from conformaesg import ConformaClient
from conformaesg.models import SupplierCertificationCreate, SupplierCreate
client = ConformaClient.from_env()
supplier = client.suppliers.create(
SupplierCreate(
name="Acme Textiles Ltd",
category="TEXTILES",
country="IT",
contact_email="procurement@example.com",
)
)
certification = client.suppliers.certifications.create(
SupplierCertificationCreate(
supplier_id=supplier.id,
certification_type="GOTS",
certificate_number="GOTS-2026-0001",
)
)
client.suppliers.certifications.attach_document(
id=certification.id,
file=Path("gots-certificate.pdf"),
)

Purchase invoice workflow

Python
from pathlib import Path
from conformaesg.models import PurchaseCreate, PurchaseTransition
purchase = client.purchases.create(
PurchaseCreate(
supplier_id="supplier-uuid",
order_number="PO-2026-0001",
order_date="2026-06-19T00:00:00.000Z",
currency="EUR",
total_amount="1249.50",
)
)
client.purchases.documents.upload(
purchase_id=purchase.id,
category="INVOICE",
file=Path("invoice.pdf"),
)
client.purchases.transition(
purchase.id,
PurchaseTransition(to_status="CONFIRMED", reason="Approved by ERP"),
)
logs = client.purchases.logs(purchase.id)

Product materials catalog sync

Python
from conformaesg.models import FabricProductCreate, SupplierProductCreate
supplier_product = client.product_materials.supplier_products.create(
SupplierProductCreate(
supplier_id="supplier-uuid",
name="Organic cotton yarn",
category="YARN",
)
)
fabric = client.product_materials.fabrics.create(
FabricProductCreate(
supplier_id="supplier-uuid",
name="Twill 220",
composition="100% cotton",
)
)

For large catalogs, process rows in batches and store external ids in your own system. The SDK does not expose bulk endpoints for this scope.

Chemical compliance

Python
from conformaesg.models import ChemicalCreate
chemical = client.chemicals.create(
ChemicalCreate(
name="Blue Dye 42",
cas_number="2580-78-1",
zdhc_level="LEVEL_3",
)
)
level_3 = client.chemicals.list(zdhc_level="LEVEL_3")

Traceability journey

Python
from conformaesg.models import ProcessingStageCreate, ProductTraceabilityCreate
journey = client.traceability.product_journeys.create(
ProductTraceabilityCreate(
traceability_name="T-Shirt SS26 supply chain",
description="Cotton to finished garment",
)
)
stage = client.traceability.product_journeys.add_stage(
journey.id,
ProcessingStageCreate(
sequence_order=1,
stage_name="Spinning",
company_type="SUPPLIER",
supplier_id="supplier-uuid",
transport_mode="TRUCK",
starts_from_company=False,
distance_km=120,
),
)
canvas = client.traceability.product_journeys.get(journey.id)