Creating segment api