const caps = await agent.getCapabilities();
if (supportsSyncCreatives(caps)) {
await agent.syncCreatives({ account, creatives, assignments });
} else if (caps.features.inlineCreativeManagement) {
await agent.createMediaBuy({
account,
idempotency_key: crypto.randomUUID(),
packages: inlineCreativesForPackages(packages, creatives, { assignments }),
});
} else {
throw new Error('Seller supports neither creative library sync nor inline creative uploads.');
}
Project library-scoped creative assets into package-scoped inline creative payloads for
create_media_buyorupdate_media_buy.The helper is pure: it performs no network calls, does not call
sync_creatives, and does not generate idempotency keys. UsesupportsSyncCreatives(caps)to decide whether the seller has a creative library. When it does not, spread this helper's result intopackages[].creativesand use a fresh idempotency key for the enclosing create/update media-buy call.