curl -X GET "https://app.commodityai.com/api/v1/sources/definitions?limit=50" \ -H "Authorization: Bearer cai_live_your_api_key_here"
{ "data": [ { "id": "123e4567-e89b-12d3-a456-426614174000", "name": "invoices", "description": "Invoice extraction for accounts payable", "source_types": ["email", "document"], "email_address": "[email protected]", "version": "1.0", "record_identifier_prefix": "INV", "created_at": "2024-01-15T10:30:00Z", "updated_at": "2024-01-20T14:22:00Z" }, { "id": "223e4567-e89b-12d3-a456-426614174001", "name": "contracts", "description": "Trade contract extraction", "source_types": ["document"], "email_address": null, "version": "1.0", "record_identifier_prefix": "CON", "created_at": "2024-01-10T09:00:00Z", "updated_at": "2024-01-18T11:45:00Z" } ], "meta": { "has_more": false, "next_cursor": null, "limit": 50 } }
Retrieve all source record definitions for your company
Show source definition
email
document
Show pagination
cursor
// 1. List all definitions const defsResponse = await fetch( 'https://app.commodityai.com/api/v1/sources/definitions', { headers: { 'Authorization': 'Bearer cai_live_your_api_key_here' } } ); const definitions = await defsResponse.json(); // 2. Find the invoices definition const invoiceDef = definitions.data.find(d => d.name === 'invoices'); // 3. Fetch records for that definition const recordsResponse = await fetch( `https://app.commodityai.com/api/v1/sources/${invoiceDef.id}/records`, { headers: { 'Authorization': 'Bearer cai_live_your_api_key_here' } } ); const records = await recordsResponse.json();
401
unauthorized
429
rate_limit_exceeded
500
internal_error