cURL
cURL Examples
Section titled “cURL Examples”Quick reference for interacting with the N’entropy EUDR Integration API using cURL.
Authentication
Section titled “Authentication”All requests require a Bearer token:
export EUDR_API_KEY="eudr_live_abc123..."Suppliers
Section titled “Suppliers”Upsert Suppliers
Section titled “Upsert Suppliers”curl -X POST https://backend.joinnentropy.com/api/v1/integration/suppliers \ -H "Authorization: Bearer $EUDR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "suppliers": [ { "externalId": "SUP-001", "name": "Amazon Timber Co.", "country": "BR", "address": "123 Forest Road", "city": "Manaus", "email": "contact@amazontimber.co", "taxId": "12.345.678/0001-90" }, { "externalId": "SUP-002", "name": "Southeast Asia Palm Ltd.", "country": "ID", "address": "456 Palm Avenue", "city": "Jakarta" } ] }'Response:
{ "success": true, "data": { "created": 2, "updated": 0, "errors": [] }}List Suppliers
Section titled “List Suppliers”curl https://backend.joinnentropy.com/api/v1/integration/suppliers \ -H "Authorization: Bearer $EUDR_API_KEY"With pagination:
curl "https://backend.joinnentropy.com/api/v1/integration/suppliers?page=1&limit=25" \ -H "Authorization: Bearer $EUDR_API_KEY"Products
Section titled “Products”Upsert Products
Section titled “Upsert Products”curl -X POST https://backend.joinnentropy.com/api/v1/integration/products \ -H "Authorization: Bearer $EUDR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "products": [ { "externalId": "PROD-001", "name": "Brazilian Eucalyptus Timber", "hsCode": "4407.11", "description": "Sustainably sourced eucalyptus planks", "supplierExternalId": "SUP-001" } ] }'List Products
Section titled “List Products”curl "https://backend.joinnentropy.com/api/v1/integration/products?page=1&limit=50" \ -H "Authorization: Bearer $EUDR_API_KEY"Batches
Section titled “Batches”Upsert Batches
Section titled “Upsert Batches”curl -X POST https://backend.joinnentropy.com/api/v1/integration/batches \ -H "Authorization: Bearer $EUDR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "batches": [ { "externalId": "BATCH-2024-001", "productExternalId": "PROD-001", "quantity": 5000, "unit": "kg", "batchDate": "2024-06-15" } ] }'List Batches
Section titled “List Batches”curl "https://backend.joinnentropy.com/api/v1/integration/batches?page=1&limit=50" \ -H "Authorization: Bearer $EUDR_API_KEY"Sync Status
Section titled “Sync Status”Overall Status
Section titled “Overall Status”curl https://backend.joinnentropy.com/api/v1/integration/sync-status \ -H "Authorization: Bearer $EUDR_API_KEY"By Entity Type
Section titled “By Entity Type”curl "https://backend.joinnentropy.com/api/v1/integration/sync-status?entityType=SUPPLIER&page=1&limit=50" \ -H "Authorization: Bearer $EUDR_API_KEY"DDS Status
Section titled “DDS Status”curl https://backend.joinnentropy.com/api/v1/integration/dds/BATCH-2024-001 \ -H "Authorization: Bearer $EUDR_API_KEY"Response:
{ "success": true, "data": { "batch": { "externalId": "BATCH-2024-001", "quantity": 5000, "syncStatus": "synced" }, "product": { "name": "Brazilian Eucalyptus Timber", "hsCode": "4407.11" }, "supplier": { "name": "Amazon Timber Co.", "country": "BR" }, "ddsSubmissions": [ { "status": "submitted", "submittedAt": "2024-06-16T12:00:00Z" } ] }}Field Mappings
Section titled “Field Mappings”curl https://backend.joinnentropy.com/api/v1/integration/field-mappings \ -H "Authorization: Bearer $EUDR_API_KEY"Webhook Events
Section titled “Webhook Events”Push Custom Events
Section titled “Push Custom Events”curl -X POST https://backend.joinnentropy.com/api/v1/integration/webhook-events \ -H "Authorization: Bearer $EUDR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "event": "sync.completed", "data": { "entityType": "SUPPLIER", "recordsAffected": 15 } }'Scripting Examples
Section titled “Scripting Examples”Sync from CSV File
Section titled “Sync from CSV File”#!/bin/bash# sync-suppliers.sh — Read suppliers from CSV and sync
API_KEY="eudr_live_abc123..."
# Build JSON from CSV (skip header)SUPPLIERS=$(tail -n +2 suppliers.csv | awk -F',' '{ printf "{\"externalId\":\"%s\",\"name\":\"%s\",\"country\":\"%s\",\"email\":\"%s\"},", $1, $2, $3, $4}' | sed 's/,$//')
curl -X POST https://backend.joinnentropy.com/api/v1/integration/suppliers \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d "{\"suppliers\":[$SUPPLIERS]}"Batch Sync with jq
Section titled “Batch Sync with jq”#!/bin/bash# Sync all suppliers, 100 at a time
API_KEY="eudr_live_abc123..."PAGE=1
while true; do RESPONSE=$(curl -s "https://backend.joinnentropy.com/api/v1/integration/suppliers?page=$PAGE&limit=100" \ -H "Authorization: Bearer $API_KEY")
COUNT=$(echo "$RESPONSE" | jq '.data.records | length') echo "Page $PAGE: $COUNT suppliers"
if [ "$COUNT" -lt 100 ]; then break fi
PAGE=$((PAGE + 1))doneHealth Check
Section titled “Health Check”#!/bin/bash# Quick connectivity test
API_KEY="eudr_live_abc123..."
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \ https://backend.joinnentropy.com/api/v1/integration/sync-status \ -H "Authorization: Bearer $API_KEY")
if [ "$HTTP_CODE" -eq 200 ]; then echo "✓ API connection OK"else echo "✗ API returned $HTTP_CODE" exit 1fiError Responses
Section titled “Error Responses”401 — Invalid Token
Section titled “401 — Invalid Token”{ "success": false, "error": { "code": "INVALID_TOKEN", "message": "The provided API token is invalid" }}403 — Insufficient Scopes
Section titled “403 — Insufficient Scopes”{ "success": false, "error": { "code": "INSUFFICIENT_SCOPES", "message": "Token missing required scopes: suppliers:write" }}400 — Validation Error
Section titled “400 — Validation Error”{ "success": false, "error": { "code": "VALIDATION_ERROR", "message": "Each supplier must have externalId and name" }}429 — Rate Limited
Section titled “429 — Rate Limited”# Handle rate limiting with exponential backofffor i in 1 2 3; do RESPONSE=$(curl -s -w "\n%{http_code}" -X POST ... ) HTTP_CODE=$(echo "$RESPONSE" | tail -1)
if [ "$HTTP_CODE" -eq 429 ]; then WAIT=$((2 ** i)) echo "Rate limited, waiting ${WAIT}s..." sleep $WAIT else echo "$RESPONSE" | head -1 break fidone