API Design Guidance: Workflows
Blog post from Tyk
APIs can model complex workflows by using hypermedia to define state transitions and provide related information, allowing clients to dynamically discover capabilities and avoid hard-coding state transitions. This approach, known as Hypermedia as the Engine of Application State (HATEOAS), enhances client-server interactions by indicating possible actions based on server-side state and user roles. A practical example is provided through an article publication API, demonstrating how hypermedia links guide the workflow from draft creation to submission and editor review, allowing or restricting actions such as updating, approving, or declining the article based on its current state. By integrating hypermedia into resource representations, APIs can become loosely coupled, focusing on specific tasks and minimizing the need for excessive data in responses, although careful design is essential to avoid the N+1 query problem. API designers are encouraged to balance the completeness and utility of responses with thoughtful endpoint design, potentially employing field selection and deep fetching patterns to optimize data retrieval.