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

# Create Project File (from URL)

POST https://api.coperniq.io/v1/projects/{project_id}/files
Content-Type: application/json

Upload a file to a project by providing its URL

Reference: https://docs.coperniq.io/api-reference/files/upload-project-file-from-url

## Authentication

- `x-api-key` header (required) — API Key authentication via header

## Request

### Path parameters

- `project_id` (integer, required) — Project identifier

### Body (application/json)

This endpoint expects an object.

- `url` (string, required) — URL of the file to upload
- `name` (string, optional) — Name of the file
- `isArchived` (boolean, optional, default: false) — Whether the file is archived
- `phaseInstanceId` (integer, optional) — Optional. The ID of the phase instance to use. If provided, the phase does not need to be started to upload a file. You can gather phase instance ids from the get project endpoint.

## Response

### 200

Successful response

- `id` (integer, required) — File identifier
- `name` (string, required) — File name
- `downloadUrl` (string, required) — URL to download the file
- `type` (string, required) — File type
- `updatedAt` (string, required) — Last update timestamp
- `createdAt` (string, required) — Creation timestamp
- `metaData` (FileMetaData, required)
- `source` (string, required) — File source (e.g., INTERNAL)
- `createdByUser` (FileCreatedByUser, required)
- `isArchived` (boolean, optional) — Whether the file is archived

## Errors

### 400 Bad Request Error

Invalid request

- `message` (string, optional)
- `code` (enum, optional)
  - Allowed values: `INTERNAL_SERVER_ERROR`
- `field` (string, optional) — Field that caused the validation error (if applicable)

### 404 Not Found Error

Resource not found

- `message` (string, optional)
- `code` (enum, optional)
  - Allowed values: `INTERNAL_SERVER_ERROR`

### 500 Internal Server Error

Internal server error

- `message` (string, optional)
- `code` (enum, optional)
  - Allowed values: `INTERNAL_SERVER_ERROR`

## Types

### FileMetaData

- `acl` (string, required) — Access control level
- `size` (integer, required) — File size in bytes
- `userId` (integer, required) — User who uploaded the file
- `mimeType` (string, required) — MIME type of the file
- `extention` (string, required) — File extension
- `originalName` (string, required) — Original file name
- `generatedName` (string, required) — Generated unique file name
- `gps` (FileMetaDataGps, optional) — GPS coordinates if applicable
- `thumbnailUrl` (string, optional) — URL to the thumbnail version
- `thumbnailName` (string, optional) — Generated thumbnail file name
- `requestFileName` (string, optional) — Original request file name

### FileCreatedByUser

- `id` (integer, optional) — User identifier
- `firstName` (string, optional) — User's first name
- `lastName` (string, optional) — User's last name

### FileMetaDataGps

GPS coordinates if applicable

## Examples

**Request**

```json
{
  "url": "https://example.com/documents/contract.pdf",
  "name": "contract.pdf"
}
```

**Response**

```json
{
  "id": 2,
  "name": "contract.pdf",
  "downloadUrl": "https://cdn.coperniq.io/files/contract.pdf",
  "metaData": {
    "acl": "private",
    "size": 51200,
    "userId": 42,
    "mimeType": "application/pdf",
    "extention": "pdf",
    "originalName": "contract.pdf",
    "generatedName": "xyz789abc123.pdf"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.coperniq.io/v1/projects/1/files"

payload = {
    "url": "https://example.com/documents/contract.pdf",
    "name": "contract.pdf"
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.coperniq.io/v1/projects/1/files';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"url":"https://example.com/documents/contract.pdf","name":"contract.pdf"}'
};

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"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.coperniq.io/v1/projects/1/files"

	payload := strings.NewReader("{\n  \"url\": \"https://example.com/documents/contract.pdf\",\n  \"name\": \"contract.pdf\"\n}")

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

	req.Header.Add("x-api-key", "<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.coperniq.io/v1/projects/1/files")

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

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"url\": \"https://example.com/documents/contract.pdf\",\n  \"name\": \"contract.pdf\"\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.coperniq.io/v1/projects/1/files")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"url\": \"https://example.com/documents/contract.pdf\",\n  \"name\": \"contract.pdf\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.coperniq.io/v1/projects/1/files', [
  'body' => '{
  "url": "https://example.com/documents/contract.pdf",
  "name": "contract.pdf"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.coperniq.io/v1/projects/1/files");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"url\": \"https://example.com/documents/contract.pdf\",\n  \"name\": \"contract.pdf\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "url": "https://example.com/documents/contract.pdf",
  "name": "contract.pdf"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.coperniq.io/v1/projects/1/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()
```