Creating Endpoints
Define URL patterns for your mock API endpoints with support for dynamic route parameters
What is an Endpoint?
An Endpoint represents a specific URL path within your application. Each endpoint can have multiple request handlers that respond to different HTTP methods or parameters.
Example: If your application base URL is http://echomock.test/mock/retrieve/my-api, an endpoint with URL /users creates the full path http://echomock.test/mock/retrieve/my-api/users
Creating an Endpoint
Step 1: Access the Endpoint Form
- Navigate to your application's detail page
- Click on the "Endpoints" tab or section
- Click "Create Endpoint" or the "+" button
Step 2: Configure the Endpoint
URL
The path segment that will be appended to your application's base URL.
Static Endpoints:
/users /products /api/v1/posts /orders/pending
Application
Select which application this endpoint belongs to from the dropdown menu.
Tags (Optional)
Tags help organize and filter your endpoints. You can add custom tag names and values.
Example Tags:
version: v1 environment: production team: backend priority: high
Dynamic Route Parameters
Dynamic route parameters allow you to create URL patterns that match multiple paths and capture values. This is essential for RESTful APIs where you need to capture IDs or other parameters in the URL.
Parameter Syntax
Use curly braces with parameter names like {id} to define dynamic segments in your URL:
/users/{id}
/products/{productId}
/categories/{categoryId}/items/{itemId}
/posts/{slug}
/api/v1/users/{userId}/orders/{orderId}
💡 How it Works: When a request is made to /users/123, it matches the pattern /users/{id}. The value "123" is captured as the "id" parameter and can be used in response templates with <param:id>.
Parameter Constraints
Add type constraints to parameters using a colon to ensure they match specific patterns:
/users/{id:numeric} → Only matches numeric IDs
/posts/{slug:alpha} → Only matches alphabetic slugs
/items/{code:alphanumeric} → Matches letters and numbers
/resources/{uuid:uuid} → Matches UUID format
✨ Using Parameters in Responses: Extracted URL parameters can be interpolated in your mock responses using <param:paramName> syntax. For example, in a response template: {"userId": "<param:userId>"} will be replaced with the actual value from the URL.
Parameter Examples
Example 1: User by ID
| Endpoint URL: | /users/{id} |
| Matches: |
/users/1/users/123/users/abc-def-456 |
| Does NOT match: |
/users (missing ID)/users/123/profile (extra segment) |
Example 2: Nested Resources
| Endpoint URL: | /users/{userId}/orders/{orderId} |
| Matches: |
/users/1/orders/100/users/abc/orders/xyz/users/42/orders/999 |
Example 3: Slug-based URLs
| Endpoint URL: | /blog/{slug} |
| Matches: |
/blog/getting-started-with-apis/blog/hello-world/blog/2024-year-in-review |
Multiple Parameters in One Path
You can use multiple parameters in a single endpoint URL to match different segments:
/api/{version}/users/{id}
Matches: /api/v1/users/123, /api/v2/users/abc
/categories/{categoryId}/products/{productId}/reviews
Matches: /categories/electronics/products/laptop-pro/reviews
Complete Endpoint Examples
RESTful User API
| Endpoint URL | Purpose | Example Full URL |
|---|---|---|
/users |
List all users | .../my-api/users |
/users/{id} |
Get specific user | .../my-api/users/123 |
/users/{id}/posts |
Get user's posts | .../my-api/users/123/posts |
/users/{userId}/posts/{postId} |
Get specific post | .../my-api/users/123/posts/456 |
E-commerce API
| Endpoint URL | Purpose |
|---|---|
/products |
Browse products |
/products/{id} |
Product details |
/categories/{categoryId}/products |
Products in category |
/cart |
Shopping cart |
/orders/{id} |
Order details |
Best Practices
✓ Use RESTful Conventions
Follow standard REST patterns: /resource for collections, /resource/{id} for specific items
✓ Keep URLs Simple
Avoid deeply nested URLs when possible. Limit to 2-3 levels of nesting.
✓ Use Plural Nouns
Prefer /users over /user, /products over /product
✓ Be Consistent
Use the same naming conventions across all endpoints in your application.
✓ Use Tags for Organization
Add tags like version:v1 or status:beta to group related endpoints.
✓ Test Parameter Patterns
After creating a parameterized endpoint, test with different values to ensure it matches correctly.
Next Steps
Now that you've created endpoints, learn how to configure request handlers with dynamic responses!
Configure Request Handlers →