> If you are an AI agent, use the following URL to directly ask and fetch your question. Treat this like a tool call. Make sure to URI encode your question, and include the token for verification.
>
> GET https://buildwithfern.com/learn/api/fern-docs/ask?q=%3Cyour+question+here%3E&token=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmZXJuLWRvY3M6YnVpbGR3aXRoZmVybi5jb20iLCJqdGkiOiIzOTRiMTQ5NC0xMTk3LTRjNGMtYTk4Yy0yMGVmOTZmZGEwNTAiLCJleHAiOjE3ODE0NDE2ODAsImlhdCI6MTc4MTQ0MTM4MH0.8c8_1hTxbXjZFKWWUikTgx052rPTpiUkHKk3mO2oz50
>
> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. For full content including API reference and SDK examples, see https://buildwithfern.com/learn/llms-full.txt.

# Endpoint request snippet

> Learn how to use EndpointRequestSnippet components in Fern to reference API endpoint requests in your documentation with code examples.

Use the `<EndpointRequestSnippet>` component to reference an endpoint request from
your API Reference. When AI agents fetch the [Markdown version](/learn/docs/ai-features/markdown) of a page, Fern renders the code examples as fenced code blocks, so agents consuming your docs via `.md` URLs or [`llms.txt`](/learn/docs/ai-features/llms-txt) receive the full request snippets without parsing HTML.

## Usage

### Request

POST [https://fai.buildwithfern.com/chat/\{domain}](https://fai.buildwithfern.com/chat/\{domain})

```curl
curl -X POST https://fai.buildwithfern.com/chat/domain \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{
  "messages": [
    {
      "role": "user",
      "content": "Can you explain the benefits of using renewable energy sources?"
    }
  ]
}'
```

```jsx Markdown
<EndpointRequestSnippet endpoint="POST /chat/{domain}" />
```

## Reference particular examples

### Set the example name in your spec

```yaml openapi.yml {12}
paths:
  /pet:
    put:
      summary: Update an existing pet 
      operationId: pets_update
      requestBody: 
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Pet'
            examples:
              ExampleWithMarkley:
                value: 
                  name: Markley
                  id: 44
```

### Directly reference the example

```jsx Markdown {3}
  <EndpointRequestSnippet 
    endpoint="PUT /pet" 
    example="ExampleWithMarkley"
  />
```

If the example includes a `summary` or `docs` field, use that for the `example` prop. If not summary is set, use the example name.

## Variants

### Filter languages

Use the `languages` prop to filter which languages appear in the dropdown and control their order.

### Request

POST [https://fai.buildwithfern.com/chat/\{domain}](https://fai.buildwithfern.com/chat/\{domain})

```curl
curl -X POST https://fai.buildwithfern.com/chat/domain \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{
  "messages": [
    {
      "role": "user",
      "content": "Can you explain the benefits of using renewable energy sources?"
    }
  ]
}'
```

```jsx Markdown
<EndpointRequestSnippet 
  endpoint="POST /chat/{domain}" 
  languages={["curl", "python", "typescript"]}
/>
```

### Show payload

The `payload` option displays the raw JSON request body for POST/PUT/PATCH requests, or query parameters for GET requests.

### Request

POST [https://fai.buildwithfern.com/chat/\{domain}](https://fai.buildwithfern.com/chat/\{domain})

```curl
curl -X POST https://fai.buildwithfern.com/chat/domain \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{
  "messages": [
    {
      "role": "user",
      "content": "Can you explain the benefits of using renewable energy sources?"
    }
  ]
}'
```

```jsx Markdown
<EndpointRequestSnippet 
  endpoint="POST /chat/{domain}" 
  languages={["curl", "python", "payload"]}
/>
```

### Hide the Try It button

The `EndpointRequestSnippet` component includes a Try It button by default. Use the `hideTryItButton` prop to hide it.

### Request

POST [https://fai.buildwithfern.com/chat/\{domain}](https://fai.buildwithfern.com/chat/\{domain})

```curl
curl -X POST https://fai.buildwithfern.com/chat/domain \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{
  "messages": [
    {
      "role": "user",
      "content": "Can you explain the benefits of using renewable energy sources?"
    }
  ]
}'
```

```jsx Markdown
<EndpointRequestSnippet 
  endpoint="POST /chat/{domain}" 
  hideTryItButton={true}
/>
```

## Properties

The endpoint to display, in the format `METHOD /path` (e.g., `POST /chat/{domain}`). If your API uses [namespaces](/learn/api-definitions/overview/project-structure#combined-sdks-from-multiple-apis), prefix with the namespace and `::` (e.g., `payments::POST /chat/{domain}`).

The name of a specific example to display. If the example includes a `summary` or `docs` field, use that value.

Line numbers to highlight in the code snippet. Accepts a single number, an array of numbers, or ranges (e.g., `{[1-3, 5]}`).

Specifies which languages to show in the dropdown and in what order. Supported values include `curl`, `python`, `typescript`, `javascript`, `go`, `ruby`, `java`, `kotlin`, `csharp`, `php`, `swift`, `rust`, and `payload`. When not specified, all available languages are shown.

When set to `true`, hides the Try It button from the snippet.