## Non-JSON Responses

`apiRequest()` decodes responses as JSON by default. For endpoints that return non-JSON payloads (XML, CSV, HTML, plain text), pass `responseType: "text"` to receive the decoded body as a string.

With `responseType: "text"` the response schema may be omitted — the raw string is returned typed `unknown`:

```typescript
const xml = await ctx.integrations.legacyApi.apiRequest({
  method: "GET",
  path: "/report.xml",
  responseType: "text",
});
// xml is the raw XML string (typed unknown)
```

To get a typed string instead, validate with a schema matching the decoded value:

```typescript
const xml = await ctx.integrations.legacyApi.apiRequest(
  { method: "GET", path: "/report.xml", responseType: "text" },
  { response: z.string() },
);
// xml is typed string
```

JSON responses (the default) always require a response schema. Omitting the schema is only allowed together with an explicit `responseType: "text"`, so unvalidated JSON is not representable.
