---
title: Schema suggestions
url: https://anyrow.ai/docs/api/schema
canonical_url: https://anyrow.ai/docs/api/schema
---

# Schema suggestions

Let Anyrow suggest a table's columns from a sample document.

- [Suggest schema from text or file (multipart)](https://anyrow.ai/docs/api/schema/schema.md): `POST /v1/projects/{project_id}/suggest-schema`

## Suggest schema from text or file (multipart)

`POST /v1/projects/{project_id}/suggest-schema`

Authentication: `Authorization: ApiKey {your_api_key}`.

### Path parameters

- `project_id` (string, required)

### Request body

Content type: `multipart/form-data` or `application/x-www-form-urlencoded` (required).

- `file` (string, optional)
- `text` (string, optional): Up to 1000000 characters.

### Returns

200 `application/json`.

- `columns` (array of objects, required)
  - `description` (string, optional)
  - `name` (string, required)
  - `type` (string, required)
- `confidence` (number, required)
- `instruction` (string, optional)

### Errors

- 404: `not_found`

Errors every endpoint can return: [Errors](https://anyrow.ai/docs/api/errors.md).

### Request

```ts title="Node.js"
import { AnyrowSDK } from "@anyrow/sdk"

const anyrow = new AnyrowSDK({
  baseURL: "https://api.anyrow.ai",
  headers: { Authorization: `ApiKey ${process.env.ANYROW_API_KEY}` },
})

const { data, error } = await anyrow.suggest.schema({
  params: {
    project_id: "{project_id}"
  },
  form: {
    file: "<file>",
    text: "string"
  },
})
```

```bash title="cURL"
curl -X POST 'https://api.anyrow.ai/v1/projects/{project_id}/suggest-schema' \
  -H 'Authorization: ApiKey {your_api_key}' \
  -F 'file=@./document.pdf' \
  -F 'text=string'
```

```js title="JavaScript"
import { openAsBlob } from "node:fs"

const body = new FormData()
body.append("file", await openAsBlob("./document.pdf"))
body.append("text", "string")

const response = await fetch("https://api.anyrow.ai/v1/projects/{project_id}/suggest-schema", {
  method: "POST",
  headers: {
    Authorization: "ApiKey {your_api_key}",
  },
  body,
})
const data = await response.json()
```

```python title="Python"
import requests

response = requests.post(
    "https://api.anyrow.ai/v1/projects/{project_id}/suggest-schema",
    headers={
        "Authorization": "ApiKey {your_api_key}",
    },
    data={
        "text": "string",
    },
    files={"file": open("./document.pdf", "rb")},
)
print(response.json())
```

### Response

```json title="200"
{
  "columns": [
    {
      "description": "string",
      "name": "string",
      "type": "string"
    }
  ],
  "confidence": 0,
  "instruction": "string"
}
```
