> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.empiriolabs.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.empiriolabs.ai/_mcp/server.

# Delete a batch file

DELETE https://api.empiriolabs.ai/v1/files/{file_id}

Deletes a batch input, output, or error file and its content. The input file of a batch that has not ended returns `409` with the code `file_in_use`; delete it after the batch ends.

Reference: https://docs.empiriolabs.ai/api-reference/api-reference/batch/delete-batch-file

## Authentication

- `Authorization` header (bearer token, required) — Pass your EmpirioLabs API key as a bearer token. The Anthropic-style `x-api-key` header is also accepted on every endpoint.

## Request

### Path parameters

- `file_id` (string, required) — Id of a batch input, output or error file.

## Response

### 200

File deleted.

- `id` (string, optional)
- `object` (enum, optional)
  - Allowed values: `file`
- `deleted` (boolean, optional)

## Errors

### 401 Unauthorized Error

The API key is missing, invalid, inactive, or expired.

- `error` (ErrorError, required)

### 403 Forbidden Error

The account or API key cannot make this request, for example a restricted account or a model that is not available on the account.

- `error` (ErrorError, required)

### 404 Not Found Error

The resource was not found, for example an unknown model ID or job ID.

- `error` (ErrorError, required)

### 409 Conflict Error

The file is the input of a batch that is still running (`file_in_use`). Delete it after the batch ends.

- `error` (ErrorError, required)

### 429 Too Many Requests Error

An account rate limit was reached: requests per minute (type `requests`, code `rate_limit_exceeded`) or tokens per minute (type `tokens`, code `token_rate_limit_exceeded`). Retry with backoff.

- `error` (ErrorError, required)

### 503 Service Unavailable Error

The file could not be deleted this time and is unchanged. Retry the request.

- `error` (ErrorError, required)

## Types

### ErrorError

- `message` (string, required) — What went wrong. For a request error it names the field to fix.
- `type` (string, required) — Error category, which follows the HTTP status: `insufficient_quota` for `402`, `requests` or `tokens` for a `429` (the limit that was reached), and `server_error` for a `5xx`. Other errors are `invalid_request_error`, or a more specific category such as `authentication_error`, `permission_error`, or `not_found_error`.
- `param` (string, required, nullable) — The request field the error is about, or null.
- `code` (string, required, nullable) — Machine-readable error code, for example `invalid_value`, `missing_required_parameter`, `invalid_api_key`, `insufficient_credits`, `model_not_found`, or `rate_limit_exceeded`. Null when the error has no code.
- `request_id` (string, required) — Request identifier. Include it when you contact support.

## Examples

**Response**

```json
{
  "id": "file_20545d7f6bfb4594af68ee90f28c6833",
  "object": "file",
  "deleted": true
}
```

**SDK Code**

```python
import requests

url = "https://api.empiriolabs.ai/v1/files/file_id"

headers = {"Authorization": "Bearer <token>"}

response = requests.delete(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.empiriolabs.ai/v1/files/file_id';
const options = {method: 'DELETE', headers: {Authorization: 'Bearer <token>'}};

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

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.empiriolabs.ai/v1/files/file_id"

	req, _ := http.NewRequest("DELETE", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.empiriolabs.ai/v1/files/file_id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.delete("https://api.empiriolabs.ai/v1/files/file_id")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('DELETE', 'https://api.empiriolabs.ai/v1/files/file_id', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.empiriolabs.ai/v1/files/file_id");
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.empiriolabs.ai/v1/files/file_id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "DELETE"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```