Skip to main content

Batch Operations

Batch operations allow processing hundreds or thousands of assets in a single call. The SDK automatically chunks large batches to stay within API limits.

Batch Createโ€‹

const result = await client.assets.batchCreate({
items: [
{ externalId: 'prod-001', vertical: 'pharmaceuticals' },
{ externalId: 'prod-002', vertical: 'pharmaceuticals' },
{ externalId: 'prod-003', vertical: 'pharmaceuticals' },
],
});

console.log(`Created: ${result.created}`);
console.log(`Failed: ${result.failed}`);

Batch Verifyโ€‹

const results = await client.assets.batchVerify([
'SER-abc123',
'SER-def456',
'SER-ghi789',
]);

for (const r of results.results) {
console.log(`${r.serial}: ${r.valid ? 'โœ“' : 'โœ—'}`);
}

Batch Revokeโ€‹

const result = await client.assets.batchRevoke(
['SER-abc123', 'SER-def456'],
'Recalled due to quality issue',
);

console.log(`Revoked: ${result.revoked}`);

Auto-Chunkingโ€‹

For batches larger than 100 items, the SDK automatically splits them into chunks and aggregates the results:

# 500 items โ†’ 5 API calls of 100 each, results merged
result = client.assets.batch_create(large_list, chunk_size=100)

You can customize the chunk size via the chunk_size parameter (default: 100).