How can I set a user's level with php

I'm working on an API that lets a third party that handles users and payments send me new user info over POST. When I create a new user, I need to be able to set the member level of that user. I'll have the user's id available to me, what function or class does Membership provide that will let me accomplish this?