Create an Endpoint
Last updated
Last updated
To create an endpoint, navigate to the Endpoints section by simply click on the Endpoints link on the side menu of your dashboard.
On the Endpoints page, you will see a list of existing endpoints if any, then click on the Create Endpoint button at the top of the table list.
On the endpoint creation page, start by entering the endpoint you want to create, then for any request type you want to setup for that endpoint, click on the plus (+) button beside it to expand it, then click on the plus (+) button below the Responses to add a new response for that request type.
When associating a response to a request type, select the response code (200 OK, 404, Not Found, etc), and then select a model from the range of existing models in the project.
Each request type can be configured to conditionally return different response codes and models when an API call is made to that endpoint with that request type. This can be helpful when you want to mimic unexpected response like it may happen in a real world scenario to see how your application handles it.
For eg: Let's say an expected response will be to return a 200 response code with a User model as response data, other responses can be added for a 404 Not-Found response, 401 Unauthorized or 500 Internal Server Error, so that any of this responses will return randomly when an API call is made for this endpoint and request type.
The probability of each response returning can be configured by clicking on the Settings button beside the model selection input. Clicking on the Settings button will open an Advanced Configuration dialog box where the Return rate for that response can be set. The higher the response rate, the higher chance of that response returning for each API call.
The response can be returned as an array or list of the selected model along with the size of list to return. This can also be set from the Advanced Configuration dialog box.