Curiosity
Flowchart showing POST /endpoint leading to response decision with branches for 200 OK and 202 Accepted.

Calling endpoints externally

Endpoints can run long. The protocol handles this with a 202 poll loop.


Three response codes:

Status Meaning Action
200 OK Done Parse body, finish
202 Accepted Still running Poll again
5xx Error Surface failure

Python poll loop:

import requests, time

url   = "https://workspace.example.com/api/endpoints/token/run/similar-tickets"
token = "your-endpoint-token"
body  = {"query": "battery drain"}

resp = requests.post(url, json=body, headers={"Authorization": f"Bearer {token}"})
cache_key = resp.headers.get("X-MSK-ENDPOINT-KEY")

while resp.status_code == 202:
    time.sleep(1)
    resp = requests.post(url, headers={
        "Authorization": f"Bearer {token}",
        "X-MSK-ENDPOINT-KEY": cache_key   # re-send cache key, omit body
    })

print(resp.json())

The X-MSK-ENDPOINT-KEY header is the optimisation: on subsequent polls, omit the body and echo the key to save bandwidth. Keep the same URL and auth header throughout.

Calling endpoints externally