> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognite.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Files

> Manage files in Cognite Data Fusion (CDF).

<Badge color="orange">Legacy data modeling</Badge>

<Note>
  This resource is part of the **asset-centric** data model.

  * **New projects**: We recommend using the **[data modeling](/api-reference/concepts/20230101/data-modeling)** service for greater flexibility and performance.
  * **Existing projects**: This resource remains fully supported for maintaining legacy applications.
</Note>

<Info>
  Looking for file upload/download? See [File content](/api-reference/concepts/20230101/file-content) for uploading and downloading files.

  This page focuses on file **metadata** management for asset-centric projects.
</Info>

The **files API** lets you create, update, search, and manage file metadata in asset-centric projects. For data modeling projects, use the [Instances API](/api-reference/concepts/20230101/instances) to manage files as instances in your data model.

Files in CDF can be related to one or more assets. For example, a file can contain a piping and instrumentation diagram (P\&ID) that shows how several assets connect.

Each file has a unique `id` generated at file creation. Specify a `fileName` when the file is created. If you want to be in control of the file identifier, you can specify an `externalId` which must be unique within a project.

A file can also have `metadata` key-value fields that are searchable. You can use these fields to store source system IDs and other information. Additionally, files can have `labels` attached to them, making it easier to organize and categorize files.

## Geographic location of files

Specify a file's geographic location, for example, its geometric features and coordinates, in the `geoLocation` field. Data in this field needs to follow the [GeoJSON specification](https://geojson.org), explained in detail in [RFC 7946](https://tools.ietf.org/html/rfc7946). The [coordinate reference system](https://tools.ietf.org/html/rfc7946#section-4) for all GeoJSON coordinates is a geographic coordinate reference system that uses the [World Geodetic System 1984 (WGS84)](https://tools.ietf.org/html/rfc7946#ref-WGS84).

### GeoJSON types

A GeoJSON object has one of 3 types:

* **Feature** - Geometric objects with (optional) extra features.
* **FeatureCollection** - A collection of Features.
* **GeometryCollection** - A collection of Geometry objects (see below).

Currently, **Feature** is the only type supported by CDF.

To describe a geographic feature, the Geometry object needs a `type` and a corresponding array of `coordinates`. Below are the supported Geometry types:

| Type            | Description                                                       | Example                                                                                                                                                |                                                                                                                                            |
| --------------- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
| Point           | Only one exact point.                                             | <Icon icon="https://apps-cdn.cogniteapp.com/@cognite/docs-portal-images/1.0.0/images/cdf/dev/concepts/resource_types/point.png" size={48} />           | `{"type": "Point", "coordinates": [30, 10]}`                                                                                               |
| MultiPoint      | Multiple points.                                                  | <Icon icon="https://apps-cdn.cogniteapp.com/@cognite/docs-portal-images/1.0.0/images/cdf/dev/concepts/resource_types/multipoint.png" size={48} />      | `{"type": "MultiPoint", "coordinates": [[10, 40], [40, 30], [20, 20], [30, 10]]}`                                                          |
| LineString      | A line.                                                           | <Icon icon="https://apps-cdn.cogniteapp.com/@cognite/docs-portal-images/1.0.0/images/cdf/dev/concepts/resource_types/linestring.png" size={48} />      | `{"type": "LineString", "coordinates": [[30, 10], [10, 30], [40, 40]]}`                                                                    |
| MultiLineString | Multiple lines.                                                   | <Icon icon="https://apps-cdn.cogniteapp.com/@cognite/docs-portal-images/1.0.0/images/cdf/dev/concepts/resource_types/multilinestring.png" size={48} /> | `{"type": "MultiLineString", "coordinates": [[[10, 10], [20, 20], [10, 40]], [[40, 40], [30, 30], [40, 20], [30, 10]]]}`                   |
| Polygon         | A closed shape. Can have inner holes of arbitrary shapes.         | <Icon icon="https://apps-cdn.cogniteapp.com/@cognite/docs-portal-images/1.0.0/images/cdf/dev/concepts/resource_types/polygon.png" size={48} />         | `{"type": "Polygon", "coordinates": [[[35, 10], [45, 45], [15, 40], [10, 20], [35, 10]], [[20, 30], [35, 35], [30, 20], [20, 30]]]}`       |
| MultiPolygon    | Multiple closed shapes. Can have inner holes of arbitrary shapes. | <Icon icon="https://apps-cdn.cogniteapp.com/@cognite/docs-portal-images/1.0.0/images/cdf/dev/concepts/resource_types/multipolygon.png" size={48} />    | `{"type": "MultiPolygon", "coordinates": [[[[30, 20], [45, 40], [10, 40], [30, 20]]], [[[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]]]}` |

### Adding geoLocation to a file

The `geoLocation` field requires the following properties:

#### type

The type of GeoJSON. CDF only supports the `Feature` type.

#### geometry

Represents the points, curves, and surfaces in coordinate space. The property consists of:

* `type` - Must be one of the following geometry types: `Point`, `MultiPoint`, `LineString`, `MultiLineString`, `Polygon`, and `MultiPolygon`. See [GeoJSON types](#geojson-types) above.

* `coordinates` - An array describing the specified geometry type. The type of geometry determines the shape of this array. For instance, a `Point` geometry type will contain a `coordinate` array consisting of just a single *x* and a single *y* coordinate. See [example 1](#example1) below.

* A `LineString` geometry type will contain a `coordinate` array with two or more points, as shown in [example 2](#example2). A `Polygon` geometry type will need to contain an array of closed `LineStrings` with four or more points, as shown in [example 3](#example3). See [the GeoJSON spec](https://tools.ietf.org/html/rfc7946#section-3.1.1) for more details on the various shapes of the `coordinates` field.

#### properties

An optional field specifying extra information to enrich the `Feature`.

**Example 1** <a name="example1" />

```json theme={"languages":{"custom":["/_languages/kuiper.json","../_languages/kuiper.json"]}}
{
  "type": "Feature",
  "geometry": {
    "type": "Point",
    "coordinates": [10.727414488792418, 6059.91713955864316]
  },
  "properties": {
    "name": "Norwegian Royal Palace"
  }
}
```

**Example 2** <a name="example2" />

```json theme={"languages":{"custom":["/_languages/kuiper.json","../_languages/kuiper.json"]}}
{
  "type": "Feature",
  "geometry": {
    "type": "LineString",
    "coordinates": [
      [35, 10],
      [45, 45],
      [15, 40],
      [10, 20],
      [35, 10]
    ]
  }
}
```

**Example 3** <a name="example3" />

Note that in this example, the `Polygon` specifies an outer and inner `LineString`.

A `Polygon` can (but doesn't have to) contain several of these `LineStrings`, where the first must be the exterior ring, and the next `LineStrings` are interior rings. This is how you would define a surface with holes.

```json theme={"languages":{"custom":["/_languages/kuiper.json","../_languages/kuiper.json"]}}
{
  "type": "Feature",
  "geometry": {
    "type": "Polygon",
    "coordinates": [
      [
        [35, 10],
        [45, 45],
        [15, 40],
        [10, 20],
        [35, 10]
      ],
      [
        [20, 30],
        [35, 35],
        [30, 20],
        [20, 30]
      ]
    ]
  }
}
```

### Upload example

```json theme={"languages":{"custom":["/_languages/kuiper.json","../_languages/kuiper.json"]}}
POST /api/v1/projects/publicdata/files
Content-Type: application/json

{
  "name": "file1",
  "externalId": "file",
  "geoLocation": {
    "type": "Feature",
    "geometry": {
      "type": "point",
      "coordinates": [
        10.727414488792418,
        6059.91713955864316
      ]
    },
    "properties": {
      "name": "Norwegian Royal Palace"
    }
  }
}
```

### Update example

```json theme={"languages":{"custom":["/_languages/kuiper.json","../_languages/kuiper.json"]}}
POST /api/v1/projects/publicdata/files/update
Content-Type: application/json

{
  "items": [
    {
      "id": 123454321,
      "update": {
        "geoLocation": {
          "set": {
            "type": "Feature",
            "geometry": {
              "type": "Point",
              "coordinates": [
                133.2,
                2.5
              ]
            },
            "properties": {
              "name": "Another place"
            }
          }
        }
      }
    }
  ]
}
```

## GeoLocation filtering

Filtering on, or searching for files matching a certain `geoLocation` requires two properties:

* `relation` - The geographic relation, either `INTERSECTS`, `WITHIN`, or `DISJOINT`.

* `shape` - The `geometry`, as described in [the geometry section](#adding-geolocation-to-a-file). Filtering is **not** available for the `MultiPoint` type.

### Filter example

```json theme={"languages":{"custom":["/_languages/kuiper.json","../_languages/kuiper.json"]}}
POST /api/v1/projects/publicdata/files/list
Content-Type: application/json

{
   "filter": {
       "geoLocation": {
         "relation": "intersects",
         "shape": {
           "type": "MultiPolygon",
           "coordinates": [[
            [[35, 10], [45, 45], [15, 40], [10, 20], [35, 10]],
            [[20, 30], [35, 35], [30, 20], [20, 30]]
            ], [
          [[36, 11], [46, 46], [16, 41], [11, 21], [36, 11]],
          [[21, 31], [36, 36], [31, 21], [21, 31]]
          ]]
         }
       }

   }
}
```

## Rate and concurrency limits

For Files rate and concurrency limits, see [API rate limits](/api-reference/concepts/20230101/rate-limits#files).
