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

# Generate Rulebook tests

> Generate suggested Rulebook test cases from a rule description, flow config, existing suite, and optional instructions.

Generates suggested tests for a Rulebook flow. Use this as a draft helper when building coverage for a new or changed rule.

## Headers

<ParamField header="Authorization" type="string" required>
  Bearer token containing your Fini workspace API key. Format: `Bearer fini_...` The key needs `write` scope.
</ParamField>

<ParamField header="Content-Type" type="string" required>
  `application/json`
</ParamField>

## Body parameters

<ParamField body="description" type="string" required>
  Description of the behavior the generated tests should cover.
</ParamField>

<ParamField body="flowConfig" type="object" required>
  Rulebook flow configuration to generate tests against.
</ParamField>

<ParamField body="existingSuite" type="object">
  Existing test suite context to avoid duplicate coverage.
</ParamField>

<ParamField body="instructions" type="string">
  Additional instructions for the generator.
</ParamField>

## Response

Returns generated test-case suggestions for the supplied Rulebook flow.

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api-prod.usefini.com/v2/hc-rules/generate-tests/public' \
    --header 'Authorization: Bearer fini_your_api_key' \
    --header 'Content-Type: application/json' \
    --data '{
    "description": "Refund-policy conversations to re-check before prompt changes.",
    "flowConfig": {
      "name": "Example",
      "value": "message"
    },
    "existingSuite": {
      "name": "Example",
      "value": "message"
    },
    "instructions": "Create a draft rule that escalates refund requests with order context."
  }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api-prod.usefini.com/v2/hc-rules/generate-tests/public', {
    method: 'POST',
    headers: {
      Authorization: 'Bearer fini_your_api_key',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
    'description': 'Refund-policy conversations to re-check before prompt changes.',
    'flowConfig': {
      'name': 'Example',
      'value': 'message'
    },
    'existingSuite': {
      'name': 'Example',
      'value': 'message'
    },
    'instructions': 'Create a draft rule that escalates refund requests with order context.'
  }
    )
  });

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://api-prod.usefini.com/v2/hc-rules/generate-tests/public",
      headers={"Authorization": "Bearer fini_your_api_key", "Content-Type": "application/json"},
      json={
      "description": "Refund-policy conversations to re-check before prompt changes.",
      "flowConfig": {
          "name": "Example",
          "value": "message"
      },
      "existingSuite": {
          "name": "Example",
          "value": "message"
      },
      "instructions": "Create a draft rule that escalates refund requests with order context."
  },
  )

  data = response.json()
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "name": "Refund escalation",
    "description": "Escalate refund requests with order context.",
    "flowConfig": {
      "type": "reply",
      "message": "Escalate refund requests with order context."
    }
  }
  ```
</ResponseExample>

<Note>
  Generated tests are suggestions. Review them before adding them to a production regression suite.
</Note>
