All jobs / Backend developer / API Development
Backend developer interview question · 0–1 years
The interviewer asks: “What status do you return when POST creates a resource?” Strongest answer?
The strongest answer
201 Created, with a Location header (and often the body). 200 means “here is a representation,” not “I created it.”
Why it works
Exactly. 201 + Location is the uniform way for a client to follow the new resource. 200 is a successful fetch or an in-place update.
What a good answer covers
- POST create → 201 + Location.
- Put the new URL in Location.
- Don't invent { success: true } on 200.
- Never 201 a failed write.
Answers that fall short
- Close, but not the strongest: 200 or 201 both mean success — I pick 200 because it's simpler.
Clients, caches and OpenAPI docs distinguish them. “Simpler” here is a lost signal. - Weak: Always 200 with { success: true } so the frontend has one path.
A boolean in a 200 throws away HTTP. Now every caller invents its own success protocol. - Red flag: Return 201 even when the insert failed, then fix it in a background job.
201 on failure is a lie. The client will GET a resource that isn't there — or worse, retry and duplicate.
Who gets asked this
More API Development questions
- The interviewer asks: “When do you nest URLs like /orders/12/items?” Strongest answer?
- In a GraphQL API, what is the schema and what is a resolver?
- The interviewer asks: “Do you return the database entity as JSON?” Strongest answer?
- The interviewer asks: “A handler throws. What does the client see?” Strongest answer?
- The interviewer asks: “How do you paginate a list endpoint?” Strongest answer?
- The interviewer asks: “Where do you validate input?” Strongest answer?
- The interviewer asks: “PUT versus PATCH?” Strongest answer?
- The interviewer asks: “How should API errors look to clients?” Strongest answer?