You need to register a variable on the task as well. Such as:
name: health check - wait for endpoints to become available
shell: curl “{{ item.endpoint }}/health”
register: endpoint_health
failed_when: endpoint_health.attempts > 5
retries: 6
delay: 10
Additionally, I notice that you are using item.endpoint, which indicates that you are using something such as with_items, but you did not include this on your task.