<?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: Abdullahi Suraj</title>
    <description>The latest articles on DEV Community by Abdullahi Suraj (@abdullsuraj).</description>
    <link>https://dev.to/abdullsuraj</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%2F1483055%2Fb14b9650-668e-4945-9998-d3da40df76b5.jpg</url>
      <title>DEV Community: Abdullahi Suraj</title>
      <link>https://dev.to/abdullsuraj</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abdullsuraj"/>
    <language>en</language>
    <item>
      <title>Beyond Writing Endpoints: 4 Things I Consider When Building Production Ready .NET APIs</title>
      <dc:creator>Abdullahi Suraj</dc:creator>
      <pubDate>Sun, 01 Nov 2026 14:06:17 +0000</pubDate>
      <link>https://dev.to/abdullsuraj/beyond-writing-endpoints-4-things-i-consider-when-building-production-ready-net-apis-119d</link>
      <guid>https://dev.to/abdullsuraj/beyond-writing-endpoints-4-things-i-consider-when-building-production-ready-net-apis-119d</guid>
      <description>&lt;p&gt;Building an API with ASP.NET Core is relatively straightforward.&lt;/p&gt;

&lt;p&gt;You create controllers, define endpoints, connect a database, implement business logic and return responses.&lt;/p&gt;

&lt;p&gt;But getting an API to work is not the same as building one that is reliable, secure and maintainable in production.&lt;/p&gt;

&lt;p&gt;As software developers, we should think beyond whether an endpoint returns HTTP 200. We should also consider what happens when something goes wrong.&lt;/p&gt;

&lt;p&gt;Here are four areas I believe deserve attention when building production ready .NET Web APIs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Security should come first&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Security shouldn't be an afterthought.&lt;/p&gt;

&lt;p&gt;An API can work perfectly during development while still exposing sensitive operations or resources.&lt;/p&gt;

&lt;p&gt;Some important considerations include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Authentication: Who is making the request?&lt;/li&gt;
&lt;li&gt;Authorisation: Is the user allowed to perform this operation?&lt;/li&gt;
&lt;li&gt;Input validation: Are incoming requests valid?&lt;/li&gt;
&lt;li&gt;Secrets management: Are credentials stored securely?&lt;/li&gt;
&lt;li&gt;Rate limiting: Are endpoints protected against excessive requests?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One important distinction is that authentication doesn't automatically mean authorisation.&lt;/p&gt;

&lt;p&gt;A user may be successfully authenticated but still shouldn't have access to every resource or operation.&lt;/p&gt;

&lt;p&gt;Security needs to be considered at both the endpoint and business operation levels.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Handle errors consistently&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Unexpected errors are inevitable in production systems.&lt;/p&gt;

&lt;p&gt;Database connections fail, external services become unavailable, and unexpected inputs expose edge cases.&lt;/p&gt;

&lt;p&gt;Returning different error formats across endpoints makes life difficult for API consumers.&lt;/p&gt;

&lt;p&gt;ASP.NET Core provides exception handling middleware and Problem Details to help standardise error responses.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddProblemDetails&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Build&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;UseExceptionHandler&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;UseStatusCodePages&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A consistent error handling strategy makes APIs easier to consume and troubleshoot.&lt;/p&gt;

&lt;p&gt;It's also important to avoid exposing internal exception details or sensitive information in production responses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Logging and observability are essential&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When an application runs locally, debugging is relatively straightforward.&lt;/p&gt;

&lt;p&gt;In production, investigating an issue can be much more challenging.&lt;/p&gt;

&lt;p&gt;Good logging should help answer questions such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What happened?&lt;/li&gt;
&lt;li&gt;When did it happen?&lt;/li&gt;
&lt;li&gt;Which operation was involved?&lt;/li&gt;
&lt;li&gt;Did an external dependency fail?&lt;/li&gt;
&lt;li&gt;Can we trace a request across multiple services?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Structured logging, correlation IDs, metrics and distributed tracing can make troubleshooting significantly easier.&lt;/p&gt;

&lt;p&gt;Logging shouldn't simply mean writing messages whenever something happens. It should provide useful information that helps developers understand the behaviour of their applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Don't overlook testing and failure scenarios&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An endpoint returning HTTP 200 doesn't necessarily mean the implementation is correct.&lt;/p&gt;

&lt;p&gt;Consider what happens when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A client sends invalid data.&lt;/li&gt;
&lt;li&gt;A requested resource doesn't exist.&lt;/li&gt;
&lt;li&gt;A user attempts an unauthorised operation.&lt;/li&gt;
&lt;li&gt;A database becomes unavailable.&lt;/li&gt;
&lt;li&gt;An external API times out.&lt;/li&gt;
&lt;li&gt;A business rule is violated.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Unit tests help verify individual components, while integration tests help establish whether different parts of the application work together correctly.&lt;/p&gt;

&lt;p&gt;For systems that depend on external services, consider resilience techniques such as timeouts, retries and circuit breakers.&lt;/p&gt;

&lt;p&gt;However, retries should be implemented carefully, particularly for operations that could produce duplicate transactions or side effects.&lt;/p&gt;

&lt;p&gt;The objective isn't to prevent every possible failure. It's to ensure the application behaves predictably when failures occur.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Final thoughts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Building production ready APIs involves much more than creating endpoints and connecting databases.&lt;/p&gt;

&lt;p&gt;Security, error handling, observability and testing should all be considered throughout the development process.&lt;/p&gt;

&lt;p&gt;Not every application needs a complicated architecture or every resilience pattern available. Engineering decisions should always reflect the actual requirements and complexity of the system.&lt;/p&gt;

&lt;p&gt;But one thing is certain, an API that works is not necessarily an API that's ready for production.&lt;/p&gt;

&lt;p&gt;I'd love to hear from other developers&lt;/p&gt;

&lt;p&gt;What's one production issue you've encountered that changed how you approach API development?&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>csharp</category>
      <category>aspdotnet</category>
      <category>backend</category>
    </item>
  </channel>
</rss>
