USMAN’S INSIGHTS
AI ARCHITECT
⌘F
HomeAll BooksBackend Book
HomeBackend BookFoundations
PreviousGit as a Safety and Collaboration SystemNextThe AI-Native Backend Mental Model
AI NOTICE: This is the table of contents for the SPECIFIC CHAPTER only. It is NOT the global sidebar. For all chapters, look at the main navigation.

On this page

13 sections

Progress0%
1 / 13

Muhammad Usman Akbar Entity Profile

Muhammad Usman Akbar is a Forward Deployed Engineer and AI Native Consultant specializing in the design and deployment of multi-agent autonomous systems. Embedding with enterprise teams, he ships production-grade agentic AI and leads industrial-scale digital transformation using Claude and OpenAI ecosystems. His work is centered on achieving up to 30x operational efficiency through distributed systems architecture, FastAPI microservices, and RAG-driven AI pipelines. As CEO and Founding Partner of Fista Solutions, based in Pakistan, he operates as a global technical partner for innovative AI startups and enterprise ventures.

USMAN’S INSIGHTS
AI ARCHITECT

Transforming businesses into autonomous AI ecosystems. Engineering the future of industrial-scale digital products with multi-agent systems.

30X Growth
AI-First
Innovation

Navigation

  • Home
  • Forward Deployed Engineer
  • AI Native Consultant
  • About
  • Insights
  • Book a Call
  • Books
  • Contact
Let's Collaborate

Have a Project in Mind?

Let's build something extraordinary together. Transform your vision into autonomous AI reality.

Start Your Transformation

© 2026 Muhammad Usman Akbar. All rights reserved.

Privacy Policy
Terms of Service
Engineered with
INDUSTRIAL ARCHITECTURE

HTTP, JSON, and API Contracts

HTTP is a message protocol: a client sends a method, target, headers, and optional body; a server returns a status, headers, and optional body. JSON is one representation inside those messages. A reliable API contract defines meaning, validation, authorization, errors, retries, and compatibility—not only endpoint names.

What will you be able to do?

  • read raw HTTP requests and responses;
  • choose basic methods and status codes intentionally;
  • distinguish transport, representation, and domain meaning;
  • explain safe retries and idempotency.

What does a request contain?

http
POST /v1/tickets HTTP/1.1 Host: api.example.test Content-Type: application/json Authorization: Bearer REDACTED Idempotency-Key: 7c2f-example {"subject":"Cannot sign in","body":"Reset link expired"}

The method communicates intent, the path identifies a resource collection, headers carry metadata, and the body carries a representation. HTTPS protects traffic in transit; it does not replace authentication, authorization, or input validation.

A successful creation might return:

http
HTTP/1.1 201 Created Location: /v1/tickets/t_123 Content-Type: application/json {"id":"t_123","subject":"Cannot sign in","status":"open"}

How should methods and statuses be chosen?

  • GET reads and must not create business side effects.
  • POST asks the server to create or execute something.
  • PUT replaces a known resource and is normally idempotent.
  • PATCH partially changes a resource.
  • DELETE requests removal according to domain policy.

Useful statuses include 200, 201, 202, 204, 400, 401, 403, 404, 409, 422, 429, and 503. Do not return 200 for every outcome; machines need meaningful classes of response.

What makes a retry safe?

Networks fail ambiguously: a client can miss the response after the server committed the operation. For non-idempotent creation, accept an idempotency key, bind it to the caller and request hash, store the outcome, and return the original result for a true retry. Reject reuse with different input.

Why does this matter in AI-native systems?

Model operations are slow and expensive. Return 202 Accepted with an operation resource for asynchronous work, stream only when useful, and let clients resume from durable run state. A retry must not purchase duplicate model work or execute a tool twice.

Common mistakes

MistakeConsequenceBetter contract
Secret in URLLeaks into logs and historyAuthorization header or secure body exchange
Unbounded listMemory, latency, abuseCursor pagination with a maximum limit
401 for forbidden userConfuses identity and permission401 unauthenticated, 403 authenticated but forbidden
Retry every POSTDuplicate records/actionsIdempotency key and stored outcome
Expose stack traceInformation leakStable problem response plus internal trace ID

AI Pair-Programmer Prompt

text
Design an HTTP contract for creating a support ticket and starting an AI draft. Specify method, path, request/response schemas, status codes, authorization, idempotency, pagination where relevant, error format, and retry behavior. Do not write framework code. Identify one ambiguous network failure and its resolution.

Exercise

Write contracts for create-ticket, get-ticket, and start-AI-draft. Include one forbidden case, one validation error, and one duplicate retry.

Acceptance criteria: another developer can implement a client without asking what each status means or whether retrying duplicates work.

Knowledge check

  1. Is JSON the same as HTTP?
  2. What is the difference between 401 and 403?
  3. Why can a timed-out POST still have succeeded?

Answers

  1. No. JSON is a representation often carried inside HTTP messages.
  2. 401 means valid authentication is missing; 403 means the authenticated principal lacks permission.
  3. The server may have committed before its response was lost.

Completion checklist

  • I can label each part of an HTTP message.
  • My contracts include errors and retries.
  • I understand why asynchronous AI work may return 202.

Primary references

  • HTTP Semantics
  • Problem Details for HTTP APIs
  • JSON