SAM API refactoring