<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Wongsaphat Nakmuang</title>
    <description>The latest articles on DEV Community by Wongsaphat Nakmuang (@beeworkk).</description>
    <link>https://dev.to/beeworkk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3963681%2F6005ffca-a098-416b-ad1e-194b2518dcb2.jpg</url>
      <title>DEV Community: Wongsaphat Nakmuang</title>
      <link>https://dev.to/beeworkk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/beeworkk"/>
    <language>en</language>
    <item>
      <title>Before You Write a Single Line: How to Plan Your API Like a Senior Engineer</title>
      <dc:creator>Wongsaphat Nakmuang</dc:creator>
      <pubDate>Mon, 08 Jun 2026 04:19:46 +0000</pubDate>
      <link>https://dev.to/beeworkk/before-you-write-a-single-line-how-to-plan-your-api-like-a-senior-engineer-1j7a</link>
      <guid>https://dev.to/beeworkk/before-you-write-a-single-line-how-to-plan-your-api-like-a-senior-engineer-1j7a</guid>
      <description>&lt;p&gt;In my second week at work, I watched a senior engineer spend 3 days refactoring an API that took 1 day to build.&lt;/p&gt;

&lt;p&gt;The endpoint worked. The logic was correct. The code was clean.&lt;/p&gt;

&lt;p&gt;But halfway through integration, the frontend team came back with a list of questions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"Why does this return a nested object here but a flat array there?"&lt;/li&gt;
&lt;li&gt;"Where's the pagination? We assumed it would be paginated."&lt;/li&gt;
&lt;li&gt;"What does error code 14 mean?"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Nobody planned it. Everyone assumed. And three days of refactoring followed.&lt;/p&gt;

&lt;p&gt;That week I learned something more valuable than any syntax or framework:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The most expensive code to write is the code you have to rewrite.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Most Developers Skip Planning
&lt;/h2&gt;

&lt;p&gt;It's not laziness. Nobody taught us this part.&lt;/p&gt;

&lt;p&gt;Tutorials teach us &lt;em&gt;how&lt;/em&gt; to build an API. They show us frameworks, authentication patterns, database queries. But they almost never show us what happens in the 30 minutes &lt;em&gt;before&lt;/em&gt; the first line of code — the thinking, the questioning, the scoping.&lt;/p&gt;

&lt;p&gt;So we do what feels natural: we open VS Code and start.&lt;/p&gt;

&lt;p&gt;The result is usually the same. We build fast, hit unexpected problems, patch things, and ship something that technically works but is painful to maintain, extend, or explain to anyone else.&lt;/p&gt;

&lt;p&gt;Here's the process I've been learning — 5 steps that happen before a single endpoint is written.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 1: Define "What Is This API?" in One Sentence
&lt;/h2&gt;

&lt;p&gt;Before anything else, you need to answer three questions. If you can't answer all three clearly, you're not ready to start.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Who&lt;/strong&gt; will call this API?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A frontend web app?&lt;/li&gt;
&lt;li&gt;A mobile client?&lt;/li&gt;
&lt;li&gt;Another backend service?&lt;/li&gt;
&lt;li&gt;A third-party developer?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The answer changes everything — response structure, authentication method, error detail level.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What&lt;/strong&gt; does it do?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Can you explain it in one sentence to someone who isn't a developer?&lt;/li&gt;
&lt;li&gt;If your answer is longer than two sentences, the scope is probably too broad.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why&lt;/strong&gt; does it need to exist?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does something similar already exist in the codebase?&lt;/li&gt;
&lt;li&gt;Are you solving a real, confirmed need — or building something "that might be useful"?&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 &lt;strong&gt;My rule:&lt;/strong&gt; If I can't explain this API to my mom in 30 seconds, I don't understand it well enough to build it yet.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Step 2: Draw the Scope Before Writing Endpoints
&lt;/h2&gt;

&lt;p&gt;Get a piece of paper. Or open a blank Markdown file. Or use Miro. The tool doesn't matter.&lt;/p&gt;

&lt;p&gt;Draw the resources your API will manage and how they relate to each other.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example — a simple task management API:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Resources:
- User
- Project  
- Task
- Comment

Relationships:
- User has many Projects
- Project has many Tasks
- Task has many Comments
- Task belongs to one User (assignee)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then for each resource, define what operations are actually needed &lt;em&gt;right now&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;Task&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="s"&gt;✅ GET    /tasks          → list tasks (with filters)&lt;/span&gt;
  &lt;span class="s"&gt;✅ POST   /tasks          → create task&lt;/span&gt;
  &lt;span class="s"&gt;✅ GET    /tasks/:id      → get single task&lt;/span&gt;
  &lt;span class="s"&gt;✅ PATCH  /tasks/:id      → update task&lt;/span&gt;
  &lt;span class="s"&gt;✅ DELETE /tasks/:id      → delete task&lt;/span&gt;

  &lt;span class="s"&gt;❌ GET    /tasks/archive  → not needed yet, skip&lt;/span&gt;
  &lt;span class="s"&gt;❌ POST   /tasks/bulk     → not needed yet, skip&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The most important discipline here is cutting scope ruthlessly.&lt;/p&gt;

&lt;p&gt;Every "nice to have" endpoint you add now is technical debt you'll maintain forever. Build what's confirmed needed. Add the rest later when there's actual demand.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 &lt;strong&gt;The question that saves hours:&lt;/strong&gt; "Is this needed for the first release, or is it something we think might be useful someday?"&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Step 3: Identify the Risks Before You Estimate
&lt;/h2&gt;

&lt;p&gt;This is the step that most junior developers skip — and it's why our estimates are almost always wrong.&lt;/p&gt;

&lt;p&gt;Before you write a single line, spend 15 minutes asking: &lt;strong&gt;"What don't I know yet?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Go through this checklist:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Authentication &amp;amp; Authorization&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does this API require authentication? What kind? (JWT, API Key, OAuth?)&lt;/li&gt;
&lt;li&gt;Are there different user roles with different permissions?&lt;/li&gt;
&lt;li&gt;Which endpoints are public? Which are protected?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Data&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Where does the data come from? An existing database? A new one?&lt;/li&gt;
&lt;li&gt;What does the current schema look like? Any constraints?&lt;/li&gt;
&lt;li&gt;Are there existing APIs that touch the same data?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Scale&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How many requests per day is realistic?&lt;/li&gt;
&lt;li&gt;Does any endpoint need pagination?&lt;/li&gt;
&lt;li&gt;Are there operations that could be slow? (File uploads, external API calls, heavy queries)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Dependencies&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does this API call any external services? (Payment gateway, email, SMS)&lt;/li&gt;
&lt;li&gt;What happens if those services are down?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every risk you find now is a problem you won't have to solve at 11pm the night before the deadline.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 &lt;strong&gt;Real talk:&lt;/strong&gt; When I got my first API task, I estimated 2 days. I hadn't asked about authentication, pagination, or the fact that the data came from a legacy system with an unusual schema. It took 5 days. The 30 minutes of risk identification would have saved me 3 days of surprises.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Step 4: Write the Contract Before the Code
&lt;/h2&gt;

&lt;p&gt;A contract is not code. It's a simple document — can be Markdown, a Notion page, a whiteboard photo — that describes what each endpoint will accept and return.&lt;/p&gt;

&lt;p&gt;Here's what a contract looks like for one endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;POST&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;/tasks&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;Description:&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;Create&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;a&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;new&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;task&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;assign&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;it&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;a&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;project&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;Request&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Body:&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;string&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;(required&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;max&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;chars)&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;string&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;(optional)&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"projectId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;uuid&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;(required)&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"assigneeId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;uuid&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;(optional)&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"dueDate"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;ISO&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;date&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;string&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;(optional)&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;Success&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Response&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;201&lt;/span&gt;&lt;span class="err"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"success"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"data"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;uuid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"todo"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"createdAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;timestamp&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;Error&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Cases:&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;missing&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;required&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;fields&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;projectId&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;not&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;found&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="mi"&gt;403&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;→&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;user&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;doesn't&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;have&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;access&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;this&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;project&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Writing this takes about 10 minutes per endpoint.&lt;/p&gt;

&lt;p&gt;The benefit is immediate: your frontend teammate can start building mock responses the same day — without waiting for you to finish the backend. You're no longer a blocker.&lt;/p&gt;

&lt;p&gt;And when you sit down to write the actual code, you already know exactly what you're building. No decision fatigue. No ambiguity. Just execution.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 &lt;strong&gt;Pro tip:&lt;/strong&gt; Show this contract to your frontend dev before you start coding. If they have questions or "that's not quite what I need" feedback — far better to discover that now than after you've shipped.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Step 5: Consult and Align With Your Team
&lt;/h2&gt;

&lt;p&gt;This is the step most tutorials never mention. And it's the one that separates developers who work well in teams from those who don't.&lt;/p&gt;

&lt;p&gt;Before you write the first line of code, take your contract and your scope document and show them to someone.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Questions to ask:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To your &lt;strong&gt;senior engineer&lt;/strong&gt; or &lt;strong&gt;tech lead&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"Does this approach make sense? Is there anything I'm missing?"&lt;/li&gt;
&lt;li&gt;"Are there patterns in this codebase I should follow?"&lt;/li&gt;
&lt;li&gt;"Do you see any risk I haven't thought of?"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To your &lt;strong&gt;frontend developer&lt;/strong&gt; (if there is one):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"Does this response structure work for what you're building?"&lt;/li&gt;
&lt;li&gt;"Is there anything you need that isn't here?"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To &lt;strong&gt;yourself&lt;/strong&gt; (seriously — write it down):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"Can I explain this to someone in 2 minutes?"&lt;/li&gt;
&lt;li&gt;"If I was sick tomorrow, could someone else pick this up?"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Asking "am I thinking about this the right way?" before writing code is not a sign of weakness. It's a sign of someone who understands that software is built by teams, not individuals.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I used to think asking questions made me look junior. Now I think the most senior thing you can do is make sure everyone is aligned before anyone starts building.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Putting It All Together
&lt;/h2&gt;

&lt;p&gt;Here's the full process in a quick reference:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;th&gt;Time&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1. Define&lt;/td&gt;
&lt;td&gt;Answer Who, What, Why&lt;/td&gt;
&lt;td&gt;15 min&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2. Scope&lt;/td&gt;
&lt;td&gt;Draw resources + cut ruthlessly&lt;/td&gt;
&lt;td&gt;20 min&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3. Risk&lt;/td&gt;
&lt;td&gt;Find the unknowns before they find you&lt;/td&gt;
&lt;td&gt;15 min&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4. Contract&lt;/td&gt;
&lt;td&gt;Write what each endpoint accepts + returns&lt;/td&gt;
&lt;td&gt;10 min/endpoint&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5. Align&lt;/td&gt;
&lt;td&gt;Show it to someone before coding&lt;/td&gt;
&lt;td&gt;15 min&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Total: roughly 1–2 hours depending on complexity.&lt;/p&gt;

&lt;p&gt;That 1–2 hours will save you many times that in rework, confusion, and late-night debugging.&lt;/p&gt;




&lt;h2&gt;
  
  
  This Connects Back to Article 1
&lt;/h2&gt;

&lt;p&gt;In my &lt;a href="https://dev.to/beeworkk/-what-im-learning-about-api-design-in-my-first-month-as-a-backend-engineer-43gf"&gt;first article&lt;/a&gt;, I wrote about designing APIs with consistent error responses, proper status codes, and clean naming.&lt;/p&gt;

&lt;p&gt;Those principles matter. But they only work if the foundation is right.&lt;/p&gt;

&lt;p&gt;Planning is that foundation.&lt;/p&gt;

&lt;p&gt;You can't consistently design good error responses if you didn't think through what errors were possible in the first place. You can't name things clearly if the scope isn't clear. You can't build something maintainable if no one agreed on what it should do.&lt;/p&gt;

&lt;p&gt;Plan first. Then design. Then build.&lt;/p&gt;




&lt;h2&gt;
  
  
  What I'm Still Learning
&lt;/h2&gt;

&lt;p&gt;Honestly — I'm still figuring out how much planning is "enough."&lt;/p&gt;

&lt;p&gt;Too little and you're building the wrong thing. Too much and you're in planning paralysis, never shipping anything.&lt;/p&gt;

&lt;p&gt;I don't have the answer yet. But I think the right amount of planning is: &lt;strong&gt;enough that your whole team can start without blocking each other.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What does your planning process look like? Do you have a system, or do you figure it out as you go? Drop it in the comments — I'm genuinely curious how more experienced engineers approach this. 🙏&lt;/p&gt;




&lt;h2&gt;
  
  
  Also
&lt;/h2&gt;

&lt;p&gt;If you want a ready-made checklist to run through before building your next API, I put one together on GitHub:&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://github.com/Bee34949/api-design-checklist" rel="noopener noreferrer"&gt;API Design Checklist — github.com/Bee34949/api-design-checklist&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's a living document — I update it as I learn. Contributions welcome.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Following along? I post about Backend Engineering and API Design — in both English 🇬🇧 and Thai 🇹🇭. See you in the next one. 🌱&lt;/em&gt;&lt;/p&gt;

</description>
      <category>api</category>
      <category>backend</category>
      <category>beginners</category>
      <category>career</category>
    </item>
    <item>
      <title># What I'm Learning About API Design in My First Month as a Backend Engineer</title>
      <dc:creator>Wongsaphat Nakmuang</dc:creator>
      <pubDate>Tue, 02 Jun 2026 07:04:21 +0000</pubDate>
      <link>https://dev.to/beeworkk/-what-im-learning-about-api-design-in-my-first-month-as-a-backend-engineer-43gf</link>
      <guid>https://dev.to/beeworkk/-what-im-learning-about-api-design-in-my-first-month-as-a-backend-engineer-43gf</guid>
      <description>&lt;p&gt;Thirty seconds into my first code review at work, my senior engineer pointed at my error response and said:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"This works. But if I'm a frontend dev consuming this at 2am trying to debug a production issue — this tells me nothing."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I had returned this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"success"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Error"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That moment changed how I think about API design forever.&lt;/p&gt;

&lt;p&gt;I'm Wongsaphat — a Junior Backend Engineer, 30 days into my first real job at INET (Internet Thailand). Before this, I spent years in university learning the theory. But theory and production are two very different things.&lt;/p&gt;

&lt;p&gt;This article isn't a guide from an expert. It's an honest look at what I'm learning — the hard way — about designing APIs that other developers actually want to use.&lt;/p&gt;




&lt;h2&gt;
  
  
  Lesson 1: Error Responses Are a Product Feature
&lt;/h2&gt;

&lt;p&gt;Before my job, I thought error handling meant wrapping code in &lt;code&gt;try/catch&lt;/code&gt; and returning &lt;code&gt;500&lt;/code&gt; if something broke.&lt;/p&gt;

&lt;p&gt;I was wrong.&lt;/p&gt;

&lt;p&gt;An error response is the first thing a frontend developer sees when something goes wrong. If it's vague, they have to come find you. If it's clear, they can fix it themselves.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What I was doing:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"success"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Error"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What I learned to do instead:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"code"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;422&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Validation failed"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"errors"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"field"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Email is required"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"field"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"password"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Password must be at least 8 characters"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The difference? The second one tells you &lt;strong&gt;exactly&lt;/strong&gt; what went wrong and &lt;strong&gt;where&lt;/strong&gt;. No guessing. No Slack messages asking "hey what does this error mean?"&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The rule I now follow:&lt;/strong&gt; Every endpoint in my API returns the same error structure. Always. No exceptions.&lt;/p&gt;




&lt;h2&gt;
  
  
  Lesson 2: Consistency Is More Important Than Cleverness
&lt;/h2&gt;

&lt;p&gt;Early on, I was inconsistent without realizing it. Some endpoints returned:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"data"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Others returned:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"result"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And some just returned the raw object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Wongsaphat"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All three "worked." But from a frontend developer's perspective, every endpoint behaved differently. They had to read the docs (or ask me) for every single endpoint.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What I do now — one response structure for everything:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Success&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;single&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;resource&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"success"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"data"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Wongsaphat"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"wongsaphat@example.com"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Success&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;list&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"success"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"data"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"pagination"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"page"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"limit"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"total"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Error&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"code"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"User not found"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pick a structure. Use it everywhere. Your future teammates will thank you.&lt;/p&gt;




&lt;h2&gt;
  
  
  Lesson 3: Auth Is Not Something You Add Later
&lt;/h2&gt;

&lt;p&gt;This one came from my professor, not my job — but I saw why it mattered once I started working.&lt;/p&gt;

&lt;p&gt;When you're building fast, it's tempting to skip auth on endpoints because "I'll add it later." The problem is later never comes, or comes too late.&lt;/p&gt;

&lt;p&gt;Here's what I now implement from day one — no exceptions:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JWT with expiry:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// ❌ Don't do this — no expiry&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;jwt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sign&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;SECRET_KEY&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// ✅ Do this — short-lived access token&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;accessToken&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;jwt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="nx"&gt;SECRET_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;expiresIn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;15m&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// ✅ Plus a refresh token for longer sessions&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;refreshToken&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;jwt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="nx"&gt;REFRESH_SECRET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;expiresIn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;7d&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Return the right status code for auth failures:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// 401 = not authenticated (no token / invalid token)&lt;/span&gt;
&lt;span class="c1"&gt;// 403 = authenticated but no permission&lt;/span&gt;

&lt;span class="c1"&gt;// ❌ Using 403 for everything&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;403&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Forbidden&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// ✅ Correct&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Authentication required&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;hasPermission&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;403&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Access denied&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Mixing up &lt;code&gt;401&lt;/code&gt; and &lt;code&gt;403&lt;/code&gt; seems small, but it breaks automated tools and confuses developers integrating with your API.&lt;/p&gt;




&lt;h2&gt;
  
  
  Lesson 4: Name Your Endpoints Like a Human, Not a Computer
&lt;/h2&gt;

&lt;p&gt;This took me embarrassingly long to internalize.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ❌ What I used to write
GET  /getUsers
POST /createUser
PUT  /updateUser/1
DELETE /deleteUser/1

// ✅ What I write now
GET    /users
POST   /users
PUT    /users/1
DELETE /users/1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The HTTP method already tells you the action. The URL should only describe the &lt;strong&gt;resource&lt;/strong&gt;. Nouns, not verbs.&lt;/p&gt;

&lt;p&gt;One more thing — be consistent with casing. Pick one and stick to it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;✅ /user-profiles     (kebab-case — recommended)
❌ /userProfiles      (camelCase — avoid in URLs)
❌ /user_profiles     (snake_case — inconsistent with REST conventions)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  What I'm Still Figuring Out
&lt;/h2&gt;

&lt;p&gt;I want to be honest — there's a lot I don't have answers to yet:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;When should I use GraphQL vs REST?&lt;/strong&gt; I understand both conceptually, but I haven't built enough real systems to have a strong opinion.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How do you version APIs without breaking existing clients?&lt;/strong&gt; I know the theory (&lt;code&gt;/api/v1/&lt;/code&gt;, &lt;code&gt;/api/v2/&lt;/code&gt;), but handling it gracefully in practice is still unclear to me.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rate limiting strategy&lt;/strong&gt; — what's the right limit for different endpoint types?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you have experience with any of these, I'd genuinely love to hear your approach in the comments.&lt;/p&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Here's what changed in my thinking since starting work:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Before&lt;/th&gt;
&lt;th&gt;After&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Error = &lt;code&gt;{ "success": false }&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Error = structured, field-level details&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Different response shape per endpoint&lt;/td&gt;
&lt;td&gt;One consistent envelope for everything&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Add auth "later"&lt;/td&gt;
&lt;td&gt;Auth from day one, JWT with expiry&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;/getUsers&lt;/code&gt;, &lt;code&gt;/createUser&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;/users&lt;/code&gt; with correct HTTP methods&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;None of this is revolutionary. But consistently doing these four things makes the difference between an API that developers enjoy working with — and one they complain about in Slack.&lt;/p&gt;




&lt;h2&gt;
  
  
  What's Next
&lt;/h2&gt;

&lt;p&gt;I'm documenting everything I learn as I go. Next up:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;REST vs GraphQL: My Honest Take as a Junior Dev&lt;/strong&gt; — what I've actually used and what I think&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;5 API Design Mistakes I Made (And How I Fixed Them)&lt;/strong&gt; — a more detailed breakdown of real errors from my first weeks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If this was useful, follow me here on Dev.to — I post regularly about Backend Engineering and API Design, in both English and Thai 🇹🇭&lt;/p&gt;

&lt;p&gt;Also check out my &lt;a href="https://github.com/Bee34949/api-design-checklist" rel="noopener noreferrer"&gt;API Design Checklist on GitHub&lt;/a&gt; — a living document I update as I learn.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Questions, disagreements, or things I got wrong? Drop them in the comments. I'm here to learn.&lt;/em&gt; 🌱&lt;/p&gt;

</description>
      <category>api</category>
      <category>backend</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
