domains / / langfuse/langfuse
Semantically correct status
Use HTTP status codes that accurately reflect the outcome of API operations. This improves API clarity and allows client applications to handle responses more intelligently.
Use HTTP status codes that accurately reflect the outcome of API operations. This improves API clarity and allows client applications to handle responses more intelligently.
- Use 201 (Created) for successful resource creation
- Use 200 (OK) for successful updates or retrievals
- Use 409 (Conflict) for duplicate resource errors, not 404 (Not Found)
- Use 202 (Accepted) for operations that will be processed asynchronously
Example for duplicate resources:
// For duplicate resource detection:
- expect(response.status).toBe(404);
+ expect(response.status).toBe(409);
Example for asynchronous processing:
PATCH: createAuthedAPIRoute({
name: "Update Single Trace",
// ...
fn: async ({ query, body, auth }) => {
// Process the request...
// Return 202 Accepted for async processing
return { status: 202, body: {
message: "Update accepted and will be processed"
}};
}
})