made API redirect URL optional