# Create a file

Source: https://deeperesearch.com/docs/api/reference/operations/createfile/

POST

/v1/files

```js
const url = 'https://deeperesearch.com/v1/files';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"filename":"requirements.pdf","mime_type":"application/pdf","size_bytes":482133}'
};


try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```sh
curl --request POST \
  --url https://deeperesearch.com/v1/files \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{ "filename": "requirements.pdf", "mime_type": "application/pdf", "size_bytes": 482133 }'
```

Step 1 of 3 to attach a file: returns a signed URL. Upload the bytes there with PUT, then call POST /v1/files/{id}/complete.

## Authorizations

- **[apiKey](https://deeperesearch.com/docs/api/reference/#apikey)**

## Request Bodyrequired

application/json

object

**filename**

required

The file’s name, e.g. requirements.pdf.

string

\>= 1 characters <= 255 characters

**mime_type**

required

The file’s type.

string

Allowed values: text/plain text/markdown application/pdf image/png image/jpeg image/webp

**size_bytes**

required

The exact size, up to 25 MB.

integer

\> 0 <= 26214400

### Example

```json
{
  "filename": "requirements.pdf",
  "mime_type": "application/pdf",
  "size_bytes": 482133
}
```

## Responses

### 201

The file, with where to upload it

application/json

object

**id**

required

string format: uuid

**object**

required

string

Allowed value: file

**filename**

required

string

**mime_type**

required

string

**size_bytes**

required

integer

\>= -9007199254740991 <= 9007199254740991

**status**

required

string

Allowed values: awaiting_upload processing ready failed

**text_chars**

required

Characters of text read from the file

Any of:

- integer

  integer

  \>= -9007199254740991 <= 9007199254740991

- null

  null

**note**

required

string | null

**created_at**

required

ISO 8601 timestamp, UTC

string

**upload**

required

object

**url**

required

Signed upload URL

string

**method**

required

string

Allowed value: PUT

**headers**

required

Send these headers with the upload

object

**_key_**

additional properties

string

**expires_in_seconds**

required

integer

\>= -9007199254740991 <= 9007199254740991

#### Example

```json
{
  "object": "file",
  "status": "awaiting_upload",
  "upload": {
    "method": "PUT"
  }
}
```

### 400

The body isn’t valid JSON (invalid_json)

application/json

object

**error**

required

object

**code**

required

Stable, machine-readable error code. See Errors in the docs.

string

**message**

required

What went wrong, written for people

string

#### Example generated

```json
{
  "error": {
    "code": "example",
    "message": "example"
  }
}
```

### 401

Missing or invalid API key (unauthorized)

application/json

object

**error**

required

object

**code**

required

Stable, machine-readable error code. See Errors in the docs.

string

**message**

required

What went wrong, written for people

string

#### Example generated

```json
{
  "error": {
    "code": "example",
    "message": "example"
  }
}
```

### 403

The key lacks the scope this needs (forbidden)

application/json

object

**error**

required

object

**code**

required

Stable, machine-readable error code. See Errors in the docs.

string

**message**

required

What went wrong, written for people

string

#### Example generated

```json
{
  "error": {
    "code": "example",
    "message": "example"
  }
}
```

### 413

The body is over 128 KB (body_too_large)

application/json

object

**error**

required

object

**code**

required

Stable, machine-readable error code. See Errors in the docs.

string

**message**

required

What went wrong, written for people

string

#### Example generated

```json
{
  "error": {
    "code": "example",
    "message": "example"
  }
}
```

### 422

Invalid request; the message names the field (invalid_request, exceeds_max_cost, vendor_unavailable, …)

application/json

object

**error**

required

object

**code**

required

Stable, machine-readable error code. See Errors in the docs.

string

**message**

required

What went wrong, written for people

string

#### Example generated

```json
{
  "error": {
    "code": "example",
    "message": "example"
  }
}
```

### 429

Rate limit, spending limit or quota reached (rate_limited, limit_reached, quota_exceeded). See Retry-After.

application/json

object

**error**

required

object

**code**

required

Stable, machine-readable error code. See Errors in the docs.

string

**message**

required

What went wrong, written for people

string

#### Example generated

```json
{
  "error": {
    "code": "example",
    "message": "example"
  }
}
```
