Skip to content

How to Run OWASP ZAP API Scan

DodaTech Updated 2026-06-24 3 min read

In this tutorial, you'll learn about How to Run OWASP ZAP API Scan. We cover key concepts, practical examples, and best practices.

ZAP API scan does not find any endpoints or reports zero alerts. The API definition file was not imported correctly, or the scanner did not parse the API structure.

The Wrong Way

# Running a standard active scan against an API endpoint
zap-active-scan.py -t https://api.example.com/v1/users

Standard scans require the spider to crawl links. APIs do not have HTML links — the spider finds nothing.

The Right Way

Step 1: Import the API definition

# For OpenAPI/Swagger:
# ZAP → Import → "OpenAPI Definition from URL"
# URL: https://api.example.com/openapi.json

# For GraphQL:
# ZAP → Import → "GraphQL Schema"
# Schema URL or introspection endpoint

# For SOAP:
# ZAP → Import → "WSDL from URL"

Step 2: Verify imported endpoints

# After import, check the Sites tree:
# - Each endpoint should appear: GET /users, POST /users, GET /users/{id}
# - Parameters are parsed from the API spec
# - Authentication schemes are noted

Step 3: Configure API authentication

# ZAP → Context → Authentication
# For API keys in headers:
# Context → "HTTP Authentication" → Add header: Authorization: Bearer <token>

# For OAuth2:
# Context → Authentication → OAuth2 → configure client credentials

Step 4: Run the API scan

# ZAP → Active Scan → select the API context
# Ensure "Input Vectors" includes:
# ✓ URL path parameters
# ✓ URL query parameters  
# ✓ POST data
# ✓ JSON body parameters
API scan complete — 23 endpoints tested, 156 parameter combinations, 8 alerts found (1 High: SQLi in /users/{id}).

Prevention

  • Always start with the OpenAPI specification for REST APIs.
  • For APIs without a spec, use ZAP's "Spider (AJAX)" which renders JavaScript SPAs that load API definitions dynamically.
  • The API parsing methodology is used in Durga Antivirus Pro's web API firewall — automatically extracting endpoints from OpenAPI specs for targeted protection.

Common Mistakes with zap api scan

  1. Misunderstanding that String is [Char] with poor performance for large text operations
  2. Using foldl instead of foldl' causing stack overflow on large lists
  3. Forgetting deriving (Show, Eq) on custom data types needed for debugging

These mistakes appear frequently in real-world OWASP code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### Why does ZAP not find all my API endpoints?

The OpenAPI spec may be incomplete or the import URL may be incorrect. Verify the spec at https://api.example.com/openapi.json in a browser. Use swagger-ui to validate the spec before importing into ZAP.

Can ZAP scan GraphQL APIs?

Yes. ZAP supports GraphQL introspection and schema scanning. Import the GraphQL schema and ZAP generates queries for each mutation and query type. Enable "GraphQL" in the active scanner's input vectors.

How do I scan APIs that require OAuth2 tokens?

Configure OAuth2 in the context settings. ZAP can obtain tokens using client credentials grant, then automatically attach the Bearer token to API requests. Ensure the token has sufficient scope for all tested endpoints.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro