Synchronous and Asynchronous APIs

Asynchronous APIs: answering a long job with 202 Accepted and a status to check, and sending signed webhooks a receiver can trust.

  • 9 cards
  • 5 questions
  • About 12 min
  • Beginner to Advanced
Share

Most API calls finish before the response is sent: the client asks, the server works, the answer comes back. Some work takes minutes, and holding a connection open that long fails at the first proxy with a timeout. An asynchronous API accepts the work at once and delivers the result later, either when the client asks for it or by calling the client back.

The topic opens on the line between synchronous and asynchronous work. A walkthrough follows a long report through 202 Accepted and a status resource, and a card on polling covers how often to ask and how the result is found. Webhooks come next, first as a contract and then with the signature that lets a receiver trust them, before a comparison sets polling beside webhooks. A gotcha covers webhooks that arrive twice or out of order, and an exercise designs a video export.

It builds on 202, 303 and Location from the status codes topic, and on recognising repeats from the topic on idempotency keys.

By the end you can decide whether an operation should be synchronous, design the 202 flow with a status resource, verify a webhook signature and its timestamp, and handle events that arrive twice or out of order.

Contents

9 cardsnot started