When pipelines with retries on `retry:when` `api_failure` condition are rerun?

What api failures are caught by retry:when api_failure in below pipeline?

test:
  script: api call
  retry:
    max: 2
    when: api_failure    

Does gitlab detect any api call failure inside the -script by analyzing network traffic, for instance or api_failure catches GitLab api failures only?

Couldn’t understand that from the docs

I would assume that it means when API calls that are outside your control fail (for example sending job logs, reporting the job as finished, etc…). So in short, internal API calls, not the ones you may dispatch with curl (for example) inside script.