Auto allocate the api struct