Skip to main content

Endpoint Configuration

The Endpoint Configuration API helps you update the settings and rules definition for a Beeceptor endpoint.

API Endpoint

MethodRequest Path
POSThttps://api.beeceptor.com/api/v1/endpoints/<my-endpoint>/configuration
  • <my-endpoint> - name of the Beeceptor endpoint

Create Mock Rules In Bulk

This API facilitates the bulk creation of mock rules, ensuring that the mock server quickly adapts to new behavior. It's particularly useful in scenarios involving continuous integration (CI) workflows, where automated tests require specific mock behaviors to be in place before execution starts.

Behavior and Limitations

  • This API replaces all existing mocking rules associated with the endpoint with the new set provided in the request. This is a complete refresh of the endpoint's behavior based on the latest specifications.
  • The operation is atomic, meaning either all rules are created successfully, or none are.
  • Each rule processed is uniquely identified by an id field. This identifier is automatically assigned.
  • In a single API call you can push up to 500 rules. The size of the HTTP request payload must not exceed 1MB.

Example - Create Two Rules

In the example below, two rules are created. Refer to the table in GET All Rules section for a detailed description of request parameters.

Request Payload

{
"rules": [
{
"enabled": true,
"mock": true,
"delay": 0,
"match": {
"method": "GET",
"value": "/my-api-path",
"operator": "SW"
},
"send": {
"status": 200,
"body": "{ \"status\": \"Awesome!\"}",
"headers": {
"Content-Type": "application/json",
"my-custom-header": "some-data"
},
"templated": false
}
},
{
"enabled": true,
"mock": true,
"delay": 0,
"match": {
"method": "GET",
"value": "/users",
"operator": "SW"
},
"send": {
"status": 200,
"body": "{ \"status\": \"Awesome!\"}",
"headers": {
"Content-Type": "application/json",
"my-custom-header": "some-data"
},
"templated": false
}
}
]
}

Success Response

The following represents a successful response with 200 as HTTP response code.

{
"success": true,
"message": "Configuration updated for the endpoint #my-mock-server",
"actionsTaken": [
"Mock rules replaced"
]
}

Error Response

For validation errors, the HTTP response code will be 400.

{
"error": {
"code": "bad_request",
"message": "should have required property 'rules'",
"parameter": ""
}
}

When there is malformed JSON in the request body, the HTTP response code will be 400.

{
"error": {
"code": "invalid_json_body",
"message": "Invaid JSON in request body"
}
}

Rate Limit Configuration

This API allows you to adjust the rate limit settings of the endpoint, offering the ability to turn rate limiting on or off and define a numeric threshold that determines the allowable number of requests to this endpoint.

Request Parameters

  • enabled: A boolean parameter that activates or deactivates the rate limit configuration.
  • threshold: Specifies the maximum number of requests permitted within the specified duration, represented as an integer.
  • duration: Defines the time frame for the rate limit, with accepted values being Second, Minute, and Hour.

For detailed information on configuring rate limits, refer to the Beeceptor documentation on rate limit configuration.

Example - Set limit to 10 requests per minute

This example configures a rate limit of 10 requests per minute for the endpoint. Rate limits can be customized to apply over seconds, minutes, or hours, offering flexible control over traffic flow.

Request Payload

{
"rateLimit": {
"enabled": true,
"threshold": 10,
"duration": "Minute"
}
}

Success Response

The following represents a successful response with 200 as HTTP response code.

{
"success": true,
"message": "Configuration updated for the endpoint #my-mock-server",
"actionsTaken": [
"Rate limit threshold updated"
]
}

Error Response

For validation errors, the HTTP response code will be 400.

{
"error": {
"code": "bad_request",
"message":"message": "/rateLimit/threshold: should be integer",
"parameter": "/rateLimit/threshold"
}
}

When there is malformed JSON in the request body, the HTTP response code will be 400.

{
"error": {
"code": "invalid_json_body",
"message": "Invaid JSON in request body"
}
}