Now that you have your schemas designed and your project structure organized, it's time to create the actual endpoints. Endpoints are the entry points to your APIβthey define how clients interact with your resources.In this chapter, we'll learn how to design and create endpoints in Apidog, focusing on how to configure requests and responses with schemas and examples. We'll use the endpoint plan we created earlier and implement the User module endpoints.
1. What Is an Endpoint?#
An endpoint is a specific URL path combined with an HTTP method that defines a single operation in your API. For example:POST /users β Create a new user
GET /users/{id} β Get a specific user
PUT /users/{id} β Update a user
DELETE /users/{id} β Delete a user
Each endpoint consists of:HTTP Method β What action to perform (GET, POST, PUT, DELETE)
Path β Where the resource is located (e.g., /users/{id})
Request β Parameters, headers, body (if needed)
Response β What the API returns (status codes, data structure, examples)
2. Creating POST /users Endpoint (Create User)#
Let's start by creating the POST /users endpoint to create a new user. This endpoint demonstrates how to configure request bodies with schemas and responses.Step 1: Create the Endpoint#
1.
In your Apidog project, navigate to the APIs section β your module
2.
Click "New Endpoint" (or β β New Endpoint)
4.
Important: Always start paths with / to comply with OpenAPI specification
Don't include the base URL (set in environments)
5.
Description: "Create a new user account in the system"
Status: "Developing" (default)
Step 2: Configure Request Body with Schema#
Since this is a POST request, we need a request body:1.
Go to the Request tab β Body
2.
Select content type: JSON
3.
Click "Schema" and select "User" from your schemas
Apidog will automatically load the User schema structure.Step 3: Customize Fields for Create Request#
The User schema includes all fields, but for the create user endpoint, we need to adjust:Fields to hide (not needed in request):id β Generated by system, not provided by client
createdAt β Set by system, not provided by client
Fields to add (needed in request but not in base schema):password β Required for account creation
1.
Hover on a field in the schema (e.g., id or createdAt)
Hidden fields won't appear in the request body
2.
Click "Add Field" or use field association
Write-only: β
(important for security)
Description: "User password"
3.
Adjust required/optional:For create endpoint: email, firstName, lastName, password are required
phone and preferences are optional
Toggle "Required" for each field as needed
Step 4: Generate Request Body Examples#
Apidog can automatically generate request body examples based on your schema:1.
Click "Add" in the request example section
2.
In the popup, click "Auto-generate"
3.
Apidog will automatically create example data that:Matches your schema structure
Includes all visible fields
Uses appropriate data types and formats
Follows validation rules (patterns, formats, etc.)
{
"email": "jane.smith@example.com",
"firstName": "Jane",
"lastName": "Smith",
"password": "securePassword123",
"phone": "+14155551234",
"preferences": {
"newsletter": true,
"notifications": false
}
}
Customize the generated example:Edit values directly in the JSON editor
Modify to show different scenarios (e.g., minimal fields, edge cases)
Add multiple examples by clicking "Add Example" and generating again
Benefits of auto-generated examples:Saves time β no need to write JSON manually
Always matches your schema β ensures consistency
Easy to customize β generate first, then edit as needed
Now let's configure what the API returns:2.
Click "Add Response" (or "Add Blank Response")
3.
Select status code: 201 (Created)
4.
Set content type: application/json
5.
Click "Schema" and select "User" schema
The User schema will be used, and Apidog automatically excludes write-only fields (like password) from responses.Step 6: Generate Response Examples#
1.
Click "Add Example" in the response section
Apidog will create example data that:Matches your schema structure
Uses appropriate data types
Follows validation rules (patterns, formats, etc.)
Respects field constraints (read-only, write-only)
Automatically excludes write-only fields (like password)
{
"id": "usr_3Oy2JIS7TMJgEXfM",
"email": "jane.smith@example.com",
"firstName": "Jane",
"lastName": "Smith",
"phone": "+14155551234",
"preferences": {
"newsletter": true,
"notifications": false
},
"createdAt": "2024-01-15T10:30:00Z"
}
Notice that password is automatically excluded (write-only field).Add multiple response examples:Click "Add Example" again
Click "Auto-generate" for each new example
Edit the generated JSON to show different scenarios (e.g., user with minimal data)
Step 7: Add Error Responses#
Every endpoint should define error responses:2.
Add common error responses:400 Bad Request β Invalid input
422 Unprocessable Entity β Validation errors
For error responses, you can use a shared Error Response Component (we'll cover this in the next chapter) or define inline with schema and examples.
3. Creating GET /users/{id} Endpoint (Get User)#
Now let's create the GET /users/{id} endpoint to retrieve a user by ID. This endpoint demonstrates how to configure path parameters and responses.Step 1: Create the Endpoint#
3.
The {id} is a path parameter (use braces {}, not colons :)
Important: Always start paths with /
4.
Description: "Retrieve user information by user ID"
When you write /users/{id} in the path, Apidog automatically recognizes {id} as a path parameter. You don't need to add it manually.In Apidog, use {parameter} syntax in paths, not :parameter
Path parameters are automatically detectedβjust write them in the path, then configure their properties
3.
Select status code: 200 (OK)
4.
Set content type: application/json
5.
Click "Schema" and select "User" schema
Step 3: Generate Response Examples#
Apidog will generate a response example matching the User schema (excluding write-only fields like password).Generate additional examples to show different scenarios
Edit to show users with or without optional fields
Step 4: Add Error Responses#
Add common error responses:404 Not Found β User not found
400 Bad Request β Invalid user ID format
4. Apidog Features for Request/Response Configuration#
Apidog provides several powerful features for working with requests and responses:Field Visibility and Association#
System-generated fields (id, createdAt) shouldn't appear in create requests
Hover on a field and click "Hide" to hide it in requests
Hidden fields won't appear in request body or examples
Add fields via association:Add fields that are only needed in specific endpoints (like password in create/login)
Fields are associated with the endpoint, not the base schema
Useful for endpoint-specific requirements
Adjust required/optional per endpoint:Base schema defines defaults
Each endpoint can override required/optional settings
Useful for partial updates (PUT endpoints where all fields are optional)
Automatic Example Generation#
Apidog's Auto-generate feature creates examples automatically:Request body/Response examples:Click "Add Example" β "Auto-generate" to create example from response schema
Excludes write-only fields automatically
Creates realistic sample data matching schema constraints
Can generate multiple examples and customize each
Fast β Generate examples in seconds
Accurate β Always matches your schema
Flexible β Edit generated examples to show different use cases
Schema References#
Reference existing schemas instead of duplicating
Changes to schema automatically reflect in all endpoints
Maintains consistency across your API
Multiple Examples#
Add multiple examples for different scenarios
Name examples for clarity
Switch between examples when testing
5. Quick Reference: Other Endpoints#
For the remaining endpoints, follow similar patterns:PUT /users/{id} (Update user):Path parameter: {id} (same as GET)
Request body: User schema with all fields optional (partial update)
Don't include: password (use separate endpoint)
Response: 200 with User schema
DELETE /users/{id} (Delete user):Response: 204 No Content (no body)
POST /user/login (Login):Request body: Simple schema with username and password
Response: 200 with token and expiresAt
POST /user/logout (Logout):No request body (or optional body)
Response: 200 with success message
6. Organizing Endpoints#
After creating endpoints, organize them:1.
Create folders under Endpoints:User Management/ β POST, GET, PUT, DELETE /users
Authentication/ β Login and logout
2.
Drag endpoints into appropriate folders
7. Key Takeaways#
Designing endpoints involves careful configuration of requests and responses:1.
Use schemas for request and response bodies to maintain consistency
2.
Customize schemas per endpoint using field visibility and associations
3.
Hide system-generated fields in requests (id, createdAt)
4.
Add endpoint-specific fields via field association (like password)
5.
Generate examples automatically from schemas, then customize
6.
Add multiple examples to show different scenarios
7.
Define error responses for comprehensive API documentation
8.
Use schema references to avoid duplication and maintain consistency
Now that you have endpoints with well-configured requests and responses, you can enhance them with reusable components. In the next chapter, we'll learn about using components and reusability to make your API design more efficient. Modified atΒ 2026-02-12 06:23:15