> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt.

# Binary data and files

Fern Definition isn't recommended for new customers and Fern isn't accepting feature requests for this format. It remains supported for existing users.

The `bytes` type allows you to handle binary data in both requests and responses.

## Sending bytes

If your API needs to send a stream of bytes (i.e. typical for assets like audio, images and other files) then
you can use the `bytes` type in the Fern Definition to model this.

```yml audio.yml
service:
  base-path: /audio
  endpoints:
    upload:
      display-name: Upload audio
      method: POST
      path: /upload
      content-type: application/octet-stream
      request:
        type: bytes
        docs: The bytes of the MP3 file that you would like to upload
```

## Receiving bytes

When handling binary data in responses, use `type: file` instead of `type: bytes`.

On the other hand, if your API is returning a stream of bytes, then you can leverage the `bytes` type as a response.

```yml textToSpeech.yml
service:
  base-path: /tts
  endpoints:
    upload:
      display-name: Upload audio
      method: POST
      path: ""
      request:
        name: TTSRequest
        body:
          properties:
            text:
              type: string
              docs: The text that you want converted to speech.
      response:
        type: file
        docs: The bytes of the audio file.
```