Yes you can do this. Just choose the fields to capture that info. Then create a code system for the url parameter.
Add the fields to the Form as Hidden, but select URL Parameter as the method for filling in the field.
Not sure how you do this in the API, but I'm sure it's easy to do.