Ravindra BagaleCourses & study guides Track your progress

AWS Cloud

API and HTTPS Interview Questions for AWS Engineers: REST, HTTP Methods, Status Codes, TLS and API Testing (35 Questions)

This page has 35 interview questions on APIs, HTTPS and API testing: 20 on how APIs and HTTPS work, and 15 on how to test APIs. Cloud engineers build, secure and debug APIs every day, so interviewers ask these at every level.

1. An everyday example: a restaurant waiter

Why does this topic matter?

Almost every AWS workload talks through APIs: browsers call your API, your code calls AWS APIs, and services call each other. If you understand requests, responses, status codes and TLS, you can debug most integration problems quickly.

Think of a waiter in a restaurant. You do not walk into the kitchen; you give your order to the waiter in a fixed format (the menu), and the waiter brings back your food or tells you "sorry, that dish is finished". An API is the waiter between a client and a system. HTTPS is like the order being passed in a sealed envelope that only the kitchen can open, so nobody in between can read or change it.

How to use this page

  • Run the curl and openssl commands against your own test endpoints.
  • All IDs, keys and domains are examples, such as account 111122223333 and example.com. Never paste real keys into commands you share.

2. Fresher level questions

Start here if you are a fresher or have less than two years of experience. Try to answer each question aloud first. Then open it and compare.

Q1. Explain an API to a non-technical person, and what makes an API "RESTful"? Fresher

An API is an agreed way for one program to ask another program for data or actions, like a waiter taking orders in a fixed format.

A REST API usually follows these ideas:

  • Resources have URLs: /orders, /orders/501.
  • Standard HTTP methods act on them: GET reads, POST creates, PUT replaces, PATCH changes part, DELETE removes.
  • Each request is stateless: it carries everything needed (including auth), so any server can handle it.
  • Responses use standard status codes and a common format, usually JSON.
  • Responses can say whether they may be cached.
Q2. Which HTTP methods are safe and which are idempotent, and why does it matter? Fresher
MethodSafe (no change)Idempotent (same result if repeated)
GETYesYes
HEAD, OPTIONSYesYes
PUTNoYes
DELETENoYes
POSTNoNo
PATCHNoNot guaranteed

Why it matters: clients, proxies and SDKs may retry after a timeout. Retrying GET or PUT is harmless; retrying POST can create two orders or two payments, so POST endpoints that matter need an idempotency key.

Q3. What do the HTTP status code families mean, and what is the difference between 401 and 403? Fresher
FamilyMeaningExamples
2xxSuccess200 OK, 201 Created, 204 No Content
3xxGo somewhere else or use your cache301 moved permanently, 302 found, 304 not modified
4xxThe client made a mistake400 bad request, 404 not found, 409 conflict, 429 too many requests
5xxThe server or something behind it failed500, 502 bad gateway, 503 unavailable, 504 gateway timeout

401 Unauthorized means the caller is not authenticated (missing or invalid credentials). 403 Forbidden means the caller is known but not allowed to do this. Retry with credentials after 401; asking again will not help after 403.

Q4. What happens, step by step, when you open https://shop.example.com in a browser? Fresher

1. DNS lookup: the browser finds the IP address (for example a Route 53 alias to CloudFront).

2. TCP connection to port 443 (or QUIC over UDP for HTTP/3).

3. TLS handshake: the server proves its identity with a certificate, and both sides agree on encryption keys.

4. HTTP request: GET / with headers such as Host, Accept and cookies, inside the encrypted channel.

5. The server (or cache) responds with a status code, headers and the body.

6. The browser renders the page and makes more requests for CSS, JS and images, often reusing the same connection.

Knowing these steps lets you say where a failure happened: DNS, network, TLS or the application.

Q5. How do you read a full HTTP request and response with curl when debugging an API? Fresher
curl -sv https://api.example.com/v1/orders/501 -H "Accept: application/json" -o /dev/null

Output:

* Connected to api.example.com (203.0.113.10) port 443
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256
* Server certificate: subject: CN=api.example.com; issuer: C=US; O=Amazon; CN=Amazon RSA 2048 M02
> GET /v1/orders/501 HTTP/2
< HTTP/2 404
< x-amzn-requestid: 7d3c1a2b-1111-2222-3333-444455556666

DNS, TCP and TLS worked; the API answered 404, so the problem is the path or the data, not the network. Lines with > are what curl sent; < is what came back. Keep the request ID to search the logs.

Q6. Which HTTP headers should every cloud engineer recognise? Fresher
  • Host: which site the request is for (many sites share one IP).
  • Content-Type: format of the body sent (application/json).
  • Accept: format the client wants back.
  • Authorization: credentials, such as "Bearer <token>" or an AWS SigV4 signature.
  • Cache-Control and ETag: whether and how long a response may be cached, and its version.
  • Location: where a new resource or a redirect points.
  • Retry-After: how long to wait after 429 or 503.
  • X-Forwarded-For and X-Forwarded-Proto: the original client IP and protocol, added by load balancers.
Q7. Why is the Host header and SNI important when many HTTPS sites share one load balancer? Fresher

One ALB or CloudFront distribution can serve many domain names.

  • SNI (Server Name Indication) is sent at the start of the TLS handshake, telling the server which domain the client wants, so it can present the right certificate before encryption starts.
  • After TLS is set up, the Host header in the HTTP request tells the load balancer which listener rule or site to use.

If a client does not send SNI (very old clients), it may get the default certificate and a name mismatch error. If the Host header is wrong, the request may hit the wrong rule and return 404.

Q21. What kinds of API tests do teams run, and what does each catch? Fresher
Test typeWhat it checks
FunctionalEach endpoint returns the right status and data for valid and invalid input
ContractResponses match the agreed schema, so clients do not break
IntegrationThe API works with real dependencies (database, queues, other services)
Performance and loadLatency and errors at expected and peak traffic
SecurityAuthentication, authorisation, input validation, rate limits
Smoke and syntheticA few key calls after each deploy and on a schedule in production

A healthy pipeline runs fast tests on every change and heavier tests before release.

Q22. How do you check an API's status code and a JSON field from a shell script? Fresher
curl -s -o body.json -w "%{http_code} %{time_total}\n" https://api.example.com/v1/health

Output:

200 0.142
jq -r '.status' body.json

Output:

ok

The API returned 200 in about 0.14 seconds and the body field status is "ok".

In a script, fail the step when the code is not 200 or the field is wrong, for example with test "$(jq -r .status body.json)" = "ok". This is the simplest smoke test after a deployment.

Q23. How do Postman collections and Newman fit into a CI pipeline? Fresher
  • A collection groups API requests with test scripts (checks on status, body and headers).
  • Environments hold variables such as base URL and tokens for dev, test and prod.
  • Newman is the command-line runner for collections, so CI can run them.
newman run orders-api.postman_collection.json -e test.postman_environment.json --reporters cli,junit

Output:

iterations 1, requests 24, test-scripts 24, assertions 61, failed 0

All 61 checks passed; the JUnit report can be shown in the pipeline. Keep secrets in the CI secret store, not in exported environment files.

Q24. What should a good API test check besides the status code? Fresher
  • Response body: required fields present, correct types and values.
  • Headers: Content-Type, caching headers, security headers.
  • Error responses: the right code (400, 401, 403, 404, 409) and a useful, consistent error body without stack traces or internal details.
  • Side effects: the record was really created, the message really sent.
  • Response time within the agreed limit.
  • That the response does not leak data the caller should not see.
Q25. How do you call an IAM-protected API Gateway endpoint from the command line? Fresher

The request must be signed with AWS Signature Version 4. Recent curl versions can do this:

curl -s --aws-sigv4 "aws:amz:ap-south-1:execute-api" --user "$AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY" -H "x-amz-security-token: $AWS_SESSION_TOKEN" https://a1b2c3d4e5.execute-api.ap-south-1.amazonaws.com/prod/reports

Output:

{"reports": 3}

curl signed the request with your temporary credentials from environment variables, and the API accepted it. Never type keys directly into commands or save them in shell history; tools such as awscurl or the SDKs read them from your profile.

3. Mid level questions

These questions check how you use the service in real projects. Interviewers expect the why, the how and one real example.

Q8. What happens in a TLS 1.3 handshake, and why is it faster than TLS 1.2? Mid level

Simplified TLS 1.3:

1. ClientHello: supported versions and ciphers, a key share, and SNI.

2. ServerHello: chosen cipher and the server's key share; from here the traffic is encrypted.

3. The server sends its certificate and a signature proving it has the private key, and Finished.

4. The client checks the certificate chain and hostname, and sends Finished. Application data flows.

TLS 1.3 needs one round trip instead of two in TLS 1.2, removes old weak ciphers, and always uses forward secrecy (a stolen server key cannot decrypt old recorded sessions). Resumed sessions can be even faster.

Q9. Mobile clients fail with "unable to verify certificate" but browsers work. How do you check the certificate chain? Mid level
openssl s_client -connect api.example.com:443 -servername api.example.com -showcerts </dev/null 2>/dev/null | grep -E "^ [0-9] s:|^Verify return code"

Output:

0 s:CN = api.example.com
Verify return code: 21 (unable to verify the first certificate)

The server sends only its own certificate, not the intermediate certificate. Browsers often fetch or cache the missing intermediate, but many mobile apps and SDKs do not.

Fix: configure the full chain (server certificate plus intermediates) on the server. ACM certificates on ALB, CloudFront and API Gateway send the chain automatically; this problem is common on self-managed Nginx or imported certificates.

Q10. How do you make a POST endpoint safe to retry? Mid level

Use an idempotency key:

  • The client generates a unique key per logical operation and sends it, for example header Idempotency-Key: 4f1c2e7a-....
  • The server stores the key with the result (in DynamoDB with a conditional write and TTL).
  • If the same key arrives again, the server returns the stored result instead of doing the work twice.
  • If the same key arrives with a different body, return an error (for example 422 or 409).

This is how payment APIs avoid double charges when a client times out and retries.

Q11. What are the common ways to version an API, and which would you choose? Mid level
ApproachExampleNotes
URL path/v1/orders, /v2/ordersEasy to see, route and cache; most common
HeaderAccept: application/vnd.shop.v2+jsonClean URLs; harder to test in a browser
Query string/orders?version=2Simple, but easy to forget and messy for caching

When to pick which: path versioning for public APIs because it is clear and works well with API Gateway stages and CloudFront behaviours; header versioning for internal APIs with strong client tooling. Whatever you pick, avoid breaking changes inside a version, and announce deprecation dates early.

Q12. Offset pagination vs cursor pagination: which should an API use for large lists? Mid level
PointOffset (?page=50&size=20)Cursor (?after=eyJpZCI6NTAxfQ)
HowSkip N rows, return the next pageReturn items after an opaque position token
Deep pagesSlow; database still reads skipped rowsSame speed for every page
Data changes while pagingItems can be skipped or repeatedStable
Jump to page 50EasyNot possible

When to pick which: cursor pagination for large or changing data and for DynamoDB (which uses LastEvaluatedKey); offset for small admin lists where users need page numbers.

Q13. What are the options to authenticate callers of an API on AWS? Mid level
  • IAM (SigV4 signing): for AWS services, internal tools and other AWS accounts.
  • JWT authorizers with Amazon Cognito or another OpenID Connect provider: for users of web and mobile apps.
  • Lambda authorizers: custom logic, for example checking tokens from a legacy system.
  • Mutual TLS: the client presents a certificate; common for B2B and devices.
  • Resource policies (REST APIs): limit by account, VPC endpoint or IP range.

Pick by who the caller is: people (JWT), AWS workloads (IAM), partners and devices (mTLS, often combined with a token).

Q14. Can an API Gateway usage plan API key be used as the authentication for an API? Mid level

It should not be. API keys in usage plans are meant for identifying a client for throttling, quotas and metering.

Reasons:

  • Keys are long-lived secrets sent with each request and are easily leaked in apps, logs or code.
  • They do not prove who the user is and have no expiry or scopes by default.

Use a real authorizer (IAM, JWT or Lambda authorizer, or mTLS) for authentication and authorisation, and add an API key on top only if you need per-customer usage plans.

Q15. What is HSTS, and what is the risk of turning it on carelessly? Mid level

HSTS (HTTP Strict Transport Security) is a response header that tells browsers to use HTTPS only for this domain for a period:

Output:

Strict-Transport-Security: max-age=31536000; includeSubDomains

Benefit: stops downgrade to plain HTTP on later visits (for example on public Wi-Fi).

Risks: with includeSubDomains, every subdomain must support HTTPS, or users cannot open it until max-age expires; preload lists are hard to undo. Start with a small max-age, confirm all subdomains have valid certificates, then increase. On CloudFront you can add it with a response headers policy.

Q16. How do you set up mutual TLS for a partner calling your API Gateway API? Mid level
  • Use a custom domain name for the API (mTLS works on custom domains, not the default execute-api endpoint, which you should disable).
  • Upload a truststore (a PEM bundle of the CA certificates that sign partner client certificates) to S3.
  • Configure the domain with the truststore URI and version.
aws apigatewayv2 create-domain-name --domain-name partners.example.com --domain-name-configurations CertificateArn=arn:aws:acm:ap-south-1:111122223333:certificate/1234abcd-12ab-34cd-56ef-1234567890ab --mutual-tls-authentication TruststoreUri=s3://truststore-111122223333/partners.pem

Result: clients without a certificate signed by a trusted CA are rejected during the TLS handshake. Plan certificate expiry and revocation with each partner.

Q26. How do you test an API Gateway REST API method without deploying it to a stage? Mid level
aws apigateway test-invoke-method --rest-api-id a1b2c3d4e5 --resource-id r2s3t4 --http-method GET --path-with-query-string "/orders/501"

Output:

{"status": 200, "latency": 87, "body": "{\"id\": \"501\", \"state\": \"SHIPPED\"}", "log": "Execution log for request ..."}

API Gateway ran the method with its integration and returned the result plus a detailed execution log (mapping templates, integration request and response).

Note: it skips authorizers and some stage settings, so still test the deployed stage end to end.

Q27. What is contract testing, and how does it differ from end-to-end testing? Mid level

Contract testing checks that a provider API and its consumers agree on the request and response format, without running the whole system.

  • Schema-based: validate responses against the OpenAPI definition in CI.
  • Consumer-driven: each consumer records the calls and fields it uses (for example with Pact), and the provider's pipeline verifies it still satisfies them.

End-to-end tests run real flows across many services: realistic, but slow and flaky. Contract tests are fast and pinpoint which change broke which consumer, so teams rely on many contract tests and a few end-to-end tests.

Q28. How do you test an API whose backend is not built yet or is expensive to call? Mid level
  • Mock integrations in API Gateway return fixed responses, so front-end teams can start.
  • sam local start-api runs your Lambda-backed API locally in containers.
  • Mock servers generated from the OpenAPI definition.
  • In unit tests, mock the AWS SDK calls (for example with botocore Stubber or moto in Python).
  • For third-party APIs, use their sandbox environment.

Replace mocks with real integration tests before release, because mocks only prove your assumptions.

Q29. Which negative test cases would you write for a "create order" API? Mid level
  • Missing or expired token (expect 401); valid token without permission (403).
  • Missing required fields, wrong types, values out of range, very long strings (400 with a clear message).
  • Unknown product ID (404 or 422).
  • Duplicate request with the same idempotency key (same result, no second order).
  • Wrong Content-Type or invalid JSON (400 or 415).
  • Too many requests (429 with Retry-After).
  • Another user's order ID in the URL (must not be readable or editable).

4. Senior level and scenario questions

These questions check design thinking and troubleshooting. Think aloud. Say what you check first, what you change, and how you prevent it next time.

Q17. Design a public API that third-party developers will use for years. What do you plan? Senior
  • Contract first: an OpenAPI definition reviewed before coding, with consistent naming, errors and pagination.
  • Versioning and a deprecation policy with dates.
  • Authentication (OAuth 2.0 client credentials or JWT) and per-client usage plans with throttling and quotas.
  • A standard error format with error codes and request IDs.
  • Idempotency keys on create and payment endpoints.
  • Documentation, SDKs, a sandbox environment and a changelog.
  • Edge protection: CloudFront and AWS WAF with rate-based rules.
  • Observability: per-client metrics, latency SLOs and alarms.
Q18. How do you encrypt traffic end to end from the browser through CloudFront and an ALB to the containers? Senior
  • Browser to CloudFront: HTTPS only (redirect HTTP), an ACM certificate in us-east-1, a modern security policy such as TLS 1.2 minimum.
  • CloudFront to ALB: origin protocol policy "HTTPS only", with the ALB's certificate matching the origin domain name CloudFront uses.
  • ALB to targets: HTTPS target groups with certificates on the containers (or a service mesh), if policy requires encryption inside the VPC; otherwise document why HTTP inside private subnets is accepted.
  • Restrict the ALB so only CloudFront can reach it (prefix list or VPC origins) and add a secret header check.
  • Monitor certificate expiry for every leg, especially certificates you manage yourself.
Q19. REST, GraphQL or gRPC: how do you choose for a new service? Senior
PointRESTGraphQLgRPC
Data shapeFixed per endpointClient asks for exact fieldsFixed by protobuf contract
TransportHTTP/1.1 or HTTP/2, JSONUsually HTTP POST, JSONHTTP/2, binary
StrengthSimple, cacheable, universalFewer round trips for complex UIsFast, typed, streaming
WeaknessOver- or under-fetchingCaching and query cost control are harderBrowsers need a proxy; harder to debug by hand
AWS fitAPI Gateway, ALBAWS AppSyncALB with gRPC, ECS or EKS services

When to pick which: REST for public and simple APIs; GraphQL for rich front ends combining many sources; gRPC for internal service-to-service calls where speed and strict contracts matter.

Q20. How would you make sure certificate expiry never causes an outage across 200 domains? Senior
  • Prefer ACM-issued certificates with DNS validation on AWS endpoints, because ACM renews them automatically as long as the validation CNAME records stay in DNS.
  • Inventory everything else (imported certificates, certificates on EC2 or on-premises, partner mTLS certificates) in one list with owners.
  • Alarm on expiry: ACM emits events and the DaysToExpiry metric; for other endpoints, a scheduled job or synthetic canary checks the expiry date.
  • Use AWS Config rules or Security Hub controls for certificates near expiry.
  • Run renewal drills and keep runbooks, because the people who set up a certificate often left before it expires.
Q30. How do you load test an API on AWS without causing an incident? Senior
  • Agree goals first: target requests per second, p95 or p99 latency, error rate.
  • Test in a production-like environment; check service quotas (Lambda concurrency, API Gateway throttling, database connections) and raise them beforehand if needed.
  • Use a load tool (k6, JMeter, Gatling) or the Distributed Load Testing on AWS solution; ramp up gradually.
  • Watch CloudWatch dashboards and stop conditions during the test.
  • Follow the AWS testing policies: load tests are allowed, but DDoS simulation is only allowed through approved partners under AWS's policy (check the current policy).
  • Tell other teams and any third-party APIs you depend on, and use stubs for partners that cannot take load.
Q31. How would you build an API testing strategy into a CI/CD pipeline? Senior
  • On every commit: unit tests and schema validation of the OpenAPI definition, lint, policy checks.
  • After deploy to a test stage: functional tests (Newman or a test framework) and contract verification for consumers.
  • Before production: integration tests with real dependencies, a short load test for risky changes, security scans.
  • After production deploy: smoke tests, then canary traffic with automatic rollback on alarms.
  • Always: synthetic canaries calling key endpoints on a schedule.

Keep tests fast and reliable; a pipeline that is slow or flaky gets bypassed.

Q32. API tests pass alone but fail randomly when the whole suite runs in a shared environment. What do you do? Senior

Likely causes and fixes:

  • Shared data: tests change records other tests read. Give each test its own data (unique IDs per run) and clean up after.
  • Order dependence: tests rely on another test running first. Make each test set up what it needs.
  • Eventual consistency: reads right after writes (DynamoDB GSIs, S3 listings, search indexes) may be stale. Poll with a timeout instead of fixed sleeps.
  • Rate limits: parallel runs hit throttling (429). Lower parallelism or use a dedicated stage.
  • Time and timezone assumptions.

Track flaky tests, quarantine them, and fix the root cause instead of adding retries everywhere.

Q33. How do you test that one customer cannot read or change another customer's data through the API? Senior

This checks object-level authorisation, a top API risk.

  • Create two test users (A and B) with their own data.
  • With A's token, call every endpoint that takes an ID using B's IDs (GET, PUT, PATCH, DELETE, and list filters). Every call must return 403 or 404, never B's data.
  • Also try changing owner fields in request bodies.
  • Automate these tests in CI for every new endpoint.
  • In the code, check ownership on the server for every request (for example DynamoDB keys that include the tenant or user from the token), never trust IDs from the client alone.
Q34. How do you monitor a production API from the user's point of view? Senior

Use synthetic monitoring:

  • CloudWatch Synthetics canaries run scripts on a schedule that call key endpoints (or click through pages), check responses and record latency and screenshots.
  • Run them from more than one Region if users are global.
  • Alarm on canary failures and on latency, linked to an on-call notification.
  • Combine with real user metrics (CloudWatch RUM for web apps) and API metrics (4xx, 5xx, latency p99).
aws synthetics get-canary-runs --name orders-api-check --max-results 1 --query "CanaryRuns[0].Status.State"

Output:

"PASSED"
Q35. How do you test that an API client handles timeouts, retries and slow dependencies correctly? Senior
  • Unit level: stub the dependency to return errors (500, 503, 429) and delays, and check the client retries with exponential backoff and jitter, gives up after a limit, and does not retry non-idempotent calls without an idempotency key.
  • Integration level: put a fault-injection proxy (for example Toxiproxy) between the service and its dependency to add latency or drop connections.
  • Environment level: use AWS Fault Injection Service experiments (for example adding latency or stopping instances) in a test account, with stop conditions on alarms.
  • Check timeouts are layered sensibly: client timeout shorter than the API Gateway or ALB timeout, which is shorter than the user's patience.

5. Frequently asked questions

Do I need to know every HTTP status code?

No. Know the families (2xx, 3xx, 4xx, 5xx) and the common ones: 200, 201, 204, 301, 304, 400, 401, 403, 404, 409, 429, 500, 502, 503 and 504.

Which tool should I learn first for API testing?

curl for quick checks and debugging, then a collection tool such as Postman (with Newman in CI), then a load testing tool such as k6 or JMeter.

What should I practise?

Build a small API with API Gateway and Lambda, call it with curl, add a custom domain with an ACM certificate, then write a test collection that runs in a pipeline.

6. Quick revision

  • GET, PUT and DELETE are idempotent; POST is not, unless you add an idempotency key.
  • 401 means "who are you?"; 403 means "I know you, but no".
  • A CloudFront certificate must be in us-east-1; regional endpoints use a certificate in their own Region.
  • API keys in usage plans are for metering and throttling, not for authentication.
  • Test the happy path, the error paths and the limits.

This page is one part of the complete AWS interview question set. Open the full list here: All 2052 AWS interview questions.