Salesforce Decode
Salesforcedecode
Back to questions
ApexAdvancedrest-apidmlintegration

Implement partial success handling in REST bulk upsert endpoint

Real World Scenario

Partner bulk order API accepts 200 orders per request. Twenty fail validation but partner expects 180 committed with per-row error detail.

Expected Answer

• Database.insert(orders, false) collecting Database.Error per index • Response envelope: successCount, failureCount, results array with index and errors • HTTP 207 Multi-Status or 200 with mixed results per API convention • Triggers fire for successful subset—document partial batch trigger behavior • Idempotency: partner retries only failed indices not full payload • Correlation Id linking request log to per-row outcomes • Test partial success with mixed valid and invalid order payloads

Follow-Up Questions & Answers

Click to expand — each follow-up includes a direct, interview-ready answer

Direct answer: Database.insert(orders, false) collecting Database.Error per index Also consider: Response envelope: successCount, failureCount, results array with index and errors In practice: HTTP 207 Multi-Status or 200 with mixed results per API convention Optimize for scale and operational observability.

Architect Perspective

Bulk API partial success is integration contract—document trigger behavior for committed subset.