ApexAdvancedrest-apiintegrationapi-design
Design Apex REST API for external system integration
Real World Scenario
Partner needs REST API to submit orders into Salesforce with OAuth and field validation mirroring UI rules.
Expected Answer
• @RestResource with URL mapping versioned /v1/orders
• Input DTO deserialization with explicit field validation before DML
• Consistent HTTP status codes: 201 created, 400 validation, 401 auth, 409 conflict
• OAuth connected app with scoped integration user minimum permissions
• Idempotency-Key header support preventing duplicate order creation
• Response envelope with Salesforce record Id and correlation ID for support
• Rate limiting awareness and bulk endpoint vs single-record endpoint separation
Follow-Up Questions & Answers
Click to expand — each follow-up includes a direct, interview-ready answer
Main difference: use case and scale. @RestResource with URL mapping versioned /v1/orders. Input DTO deserialization with explicit field validation before DML. Pick based on your integration pattern and team capability. Apex REST is contract—publish OpenAPI spec and treat breaking changes with version bumps. Optimize for scale and operational observability.
Architect Perspective
Apex REST is contract—publish OpenAPI spec and treat breaking changes with version bumps.