---
title: ApiOperation
description: >-
  The `operation` frontmatter schema, one endpoint or GraphQL field per note. An
  OpenAPI or GraphQL SDL plugin emits this shape.
updated_at: '2026-10-27T22:44:23+01:00'
created_at: '2026-09-25T10:30:20+02:00'
symbol:
  kind: type
  name: ApiOperation
  signatures:
    - >-
      type ApiOperation =
      [[reference/api/theme-api-docs/RestOperation|RestOperation]] |
      [[reference/api/theme-api-docs/WebSocketOperation|WebSocketOperation]] |
      [[reference/api/theme-api-docs/GraphqlOperation|GraphqlOperation]]
  source: >-
    https://github.com/mia-cx/svartz/blob/711f3906a713c8b9a5a572d0f34c85e90c3bc3d1/themes/api-docs/src/lib/api.ts#L168
---

# ApiOperation

```yaml
operation:
  protocol: rest
  method: POST
  path: /pets/{petId}/photos
  auth: bearer
  parameters: [{ name: petId, in: path, type: string, required: true, example: p_42 }]
  requestBody: { schema: { $ref: NewPhoto } }
  responses:
    201: { description: Created, schema: { $ref: Photo } }
    202: { description: Queued, empty: true }
    200: { description: The photo, contentType: image/jpeg }
```

`server` overrides the theme's `baseUrl` for one operation.
`requestBody.contentType` defaults to `application/json`;
`application/x-www-form-urlencoded`, `multipart/form-data`, and text types
encode the example to match. A response's `headers` map names to example
values. `client: browser` marks a page or form action, shown as an HTML form
and a raw HTTP request rather than API client code.

`protocol: websocket` takes the same `path`, `server`, `auth`, `parameters`,
and `responses` for the upgrade request, plus the messages and close codes:

```yaml
operation:
  protocol: websocket
  path: /v1/stream
  responses: { 101: { description: Switching Protocols }, 429: { description: Too many sockets } }
  messages:
    - { direction: send, name: ping, example: ping }
    - { direction: receive, name: digest, schema: { $ref: Digest } }
  close: { 4003: The token lost its scope. }
```
