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

# Create a file

POST https://api.airtop.ai/api/v1/files
Content-Type: application/json

Reference: https://docs.airtop.ai/api-reference/airtop-api/files/create

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Body (application/json)

This endpoint expects an object.

- `fileName` (string, required) — Name of the file, must be unique within the session the file is used with
- `fileType` (enum, optional, default: customer_upload) — Type of the file
  - Allowed values: `browser_download`, `screenshot`, `recording`, `customer_upload`
- `id` (string, optional) — File ID. Must be unique. Leave blank to get one generated for you
- `sessionIds` (list of string, optional) — IDs of the associated sessions

## Response

### 200

OK

- `data` (CreateFileV1, required)
- `meta` (EnvelopeDefaultMeta, required)
- `errors` (list of Issue, optional)
- `warnings` (list of Issue, optional)

## Types

### CreateFileV1

- `fileBytes` (long, required) — Size of the file in bytes
- `fileName` (string, required) — Name of the file
- `fileType` (enum, required, default: customer_upload) — Type of the file
  - Allowed values: `browser_download`, `screenshot`, `recording`, `customer_upload`
- `id` (string, required) — ID of the file
- `orgId` (string, required) — ID of the organization
- `status` (enum, required, default: deleted) — Status of the file
  - Allowed values: `available`, `uploading`, `upload_failed`, `deleted`
- `uploadStartTime` (datetime, required) — Time when the file upload was started
- `uploadUrl` (string, required) — URL to upload the file
- `sessionIds` (list of string, optional) — IDs of the associated sessions

### EnvelopeDefaultMeta

- `requestId` (string, optional)

### Issue

- `message` (string, required) — Message describing the issue.
- `code` (string, optional) — Issue code.
- `details` (map from string to any, optional) — Any associated details.
- `reason` (string, optional) — Underlying reason for the issue.

## Examples

**Request**

```json
{
  "fileName": "fileName"
}
```

**Response**

```json
{
  "data": {
    "fileBytes": 1000000,
    "fileName": "fileName",
    "fileType": "browser_download",
    "id": "id",
    "orgId": "orgId",
    "status": "available",
    "uploadStartTime": "2024-01-15T09:30:00Z",
    "uploadUrl": "uploadUrl",
    "sessionIds": [
      "sessionIds"
    ]
  },
  "meta": {
    "requestId": "requestId"
  },
  "errors": [
    {
      "message": "message",
      "code": "code",
      "details": {
        "key": "value"
      },
      "reason": "reason"
    }
  ],
  "warnings": [
    {
      "message": "message",
      "code": "code",
      "details": {
        "key": "value"
      },
      "reason": "reason"
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://api.airtop.ai/api/v1/files"

payload = { "fileName": "fileName" }
headers = {
    "Authorization": "Bearer <apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```typescript
import { AirtopClient } from "@airtop/sdk";

const client = new AirtopClient({ apiKey: "YOUR_API_KEY" });
await client.files.create({
    fileName: "fileName"
});

```

```go
package main

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

func main() {

	url := "https://api.airtop.ai/api/v1/files"

	payload := strings.NewReader("{\n  \"fileName\": \"fileName\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <apiKey>")
	req.Header.Add("Content-Type", "application/json")

	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.airtop.ai/api/v1/files")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"fileName\": \"fileName\"\n}"

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.post("https://api.airtop.ai/api/v1/files")
  .header("Authorization", "Bearer <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"fileName\": \"fileName\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.airtop.ai/api/v1/files', [
  'body' => '{
  "fileName": "fileName"
}',
  'headers' => [
    'Authorization' => 'Bearer <apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.airtop.ai/api/v1/files");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"fileName\": \"fileName\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["fileName": "fileName"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.airtop.ai/api/v1/files")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

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()
```