> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alumio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Mock requests

> Return a mock response instead of executing the request.

export const FormField = ({property, label, required = false, diType, uiPatterns, children}) => {
  const patterns = Array.isArray(uiPatterns) ? uiPatterns : uiPatterns ? [uiPatterns] : [];
  return <div style={{
    margin: '1.5rem 0'
  }}>
      <div style={{
    display: 'flex',
    alignItems: 'baseline',
    flexWrap: 'wrap',
    gap: '0.5rem',
    marginBottom: '0.25rem'
  }}>
        <strong>{label}</strong>
        <span style={{
    fontSize: '0.7rem',
    fontWeight: 600,
    textTransform: 'uppercase',
    letterSpacing: '0.04em',
    color: required ? '#6241f5' : '#6b7280'
  }}>
          {required ? 'Required' : 'Optional'}
        </span>
      </div>

      <div>{children}</div>

      {diType || patterns.length > 0 ? <p style={{
    fontSize: '0.85rem',
    color: '#6b7280',
    marginBottom: 0
  }}>
          {diType ? <>
              See the <a href={`/references/${diType}`}>{diType}</a> reference.{' '}
            </> : null}
          {patterns.length > 0 ? <>
              Accepts a <a href={`/documentation/placeholders-and-patterns/patterns#${patterns[0]}`}>pattern</a>.
            </> : null}
        </p> : null}
    </div>;
};

Returns a response you define instead of actually contacting the target service. The connection short-circuits the call and hands back the status code, headers and body you configured, so no real network request is made. Use this for testing and development, when you want to try an integration without hitting a live API, or to stand in for a service that is not available yet.

You can optionally add request matchers. When you do, the mock response is only returned for requests that match every matcher you add; any request that does not match is sent on to the real service as normal. With no matchers, every request is mocked.

This documentation describes: [Schema](/schemas/http-client-plugin-configurator/mock)

## Fields

<FormField property="response" label="Response" required diType="http-response">
  The response to return instead of calling the service. You configure its status code, headers and body here, and that is exactly what the connection hands back.
</FormField>

<FormField property="matchers" label="Request matchers" diType="http-request-matcher">
  An optional list of conditions that decide which requests get the mock response. A request must match every matcher in the list to be mocked; requests that do not match are sent to the real service. Leave the list empty to mock every request.
</FormField>

## Sample data

This plugin returns a fixed response rather than transforming data, so there is no before/after to show. The example below returns a `200` response with a small JSON body for every request, with no matchers so all requests are mocked.

| Field            | Value                           |
| ---------------- | ------------------------------- |
| Response         | `200` with a JSON body          |
| Request matchers | (none: every request is mocked) |

```json Configuration theme={null}
{
  "prototype": "mock",
  "parameters": {
    "response": {
      "prototype": "response",
      "parameters": {
        "statusCode": 200,
        "headers": { "Content-Type": "application/json" },
        "body": "{\"status\":\"ok\"}"
      }
    },
    "matchers": []
  }
}
```
