> 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.eyJpc3MiOiJmZXJuLWRvY3M6YnVpbGR3aXRoZmVybi5jb20iLCJqdGkiOiI5MmI1ZmEyZC02YzJiLTRiNjUtYmRhYS05ZDczOTM2NDNjYzIiLCJleHAiOjE3ODA2NjI2NzgsImlhdCI6MTc4MDY2MjM3OH0.QkcwaZOP5uzFYPPta4zvvFlc4k9W8ze9_4rkJJepE7Q
>
> 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.

# HTTP JSON 端点

> 在 Fern Definition 的 endpoints 键下定义 HTTP JSON 端点，包括路径、方法、请求体、响应和示例。

端点在 Fern 中定义在 `endpoints` 键下。以下是定义单个 REST 端点的示例：

```yml title="users.yml" maxLines=0
service: 
  base-path: /users 
  auth: false 
  endpoints: 
    createUser: 
      path: /create 
      method: POST 
      request: 
        body: 
          properties: 
            userName: string
```

## 示例

您可以通过使用 `examples` 键来提供请求和响应的示例。

```yaml {11-17}
service:
  base-path: /users
  auth: false
  endpoints:
    getUser:
      path: /{userId}
      path-parameters:
        userId: string
      method: GET
      response: User
      examples:
        - path-parameters:
            userId: alice-user-id
          response:
            body:
              userId: alice-user-id
              name: Alice
```