# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
This site has an agentic ask interface you may use to query the documentation dynamically by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.getafile.io/index.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

---

# Introduction

Welcome to the GetaFile API documentation.

## What is GetaFile?

GetaFile is a subscription-based web application delivering version-controlled files via customised web links created by subscribers. Read more about GetaFile [here](https://www.getafile.online).

## Getting Access to the GetaFile API

To get started with the GetaFile API, register an account at [https://getafile.io/auth/register](https://getafile.online/app#/register)

{% hint style="info" %}
&#x20;Once you have registered your account, verified and setup your Two-Factor authentication you'll need to create an API token.
{% endhint %}

## Create an API Token

To generate an API token, go to your Profile and select "API TOKENS". Enter a name for the token and click "Generate token".

<figure><img src="https://1822885327-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIl50zPgPqmR5_k56xs%2Fuploads%2Fy4aKbB9ekTv3HKG4ViLm%2Fgetafile-api-tokens.png?alt=media&amp;token=a0048fbb-ded5-4410-bd69-be174df4541c" alt=""><figcaption></figcaption></figure>

To revoke an API Token, click the delete icon next to the token you wish to revoke.

## Using the API Token

Once you have generated an API Token, include it in the Authorization header for each request.

There are 2 regions for GetaFile. Depending on where your account is located, use the following base URLs:\
\
**Oceanic, Asia**\
`au.getafile.io/api/v1`\
\
**Americas**\
`us.getafile.io/api/v1`

**Europe**\
`eu.getafile.io/api/v1`

<mark style="color:blue;">`GET`</mark> `https://{region}.getafile.io/api/v1/auth/checklogin`

Set the Authorization header for each request.

#### Headers

| Name          | Type   | Description                            |
| ------------- | ------ | -------------------------------------- |
| Authorization | string | Bearer ADeEW12312ZzSDS2112432xxxxxxxxx |

{% tabs %}
{% tab title="200 " %}

```
{
    email: "test@test.net"
    first_name: "Test"
    id: 1
    last_name: "User"
}
```

{% endtab %}

{% tab title="401 Returned if there is an issue with the Token." %}

```
```

{% endtab %}
{% endtabs %}


# Teams

Get all the teams you are a member of

<mark style="color:blue;">`GET`</mark> `https://{region}.getafile.io/api/v1/auth/teams`

This endpoint allows you to get your current usage inside getafile.

{% tabs %}
{% tab title="200 Current usage successfully retrieved." %}

```json
[
    {
        "id": 1,
        "name": "Test Team",
        "role": "owner"
    }
]
```

{% endtab %}
{% endtabs %}


# Current Usage

Get your current usage inside getafile

## Fetch the current usage for the specified team

<mark style="color:blue;">`GET`</mark> `https://{region}.getafile.io/api/v1/auth/teams/:team_id/currentusage`

This endpoint allows you to get your current usage for a team inside getafile.

#### Path Parameters

| Name                                       | Type   | Description        |
| ------------------------------------------ | ------ | ------------------ |
| team\_id<mark style="color:red;">\*</mark> | Number | The ID of the team |

{% tabs %}
{% tab title="200 Current usage successfully retrieved." %}

```json
{
    "files": [
        {
            "id": 93,
            "name": "test",
            "url": "https://test.getafile.online/test/test",
            "serves": 5
        }
    ],
    "domains": 1
}
```

{% endtab %}
{% endtabs %}


# List Domains

List all the domains that you have access to.

<mark style="color:blue;">`GET`</mark> `https://{region}.getafile.io/api/v1/teams/:team_id/domains`

This endpoint allows you to get the list of Domains that you have access to.

#### Path Parameters

| Name                                       | Type   | Description    |
| ------------------------------------------ | ------ | -------------- |
| team\_id<mark style="color:red;">\*</mark> | number | ID of the team |

{% tabs %}
{% tab title="200 Domains successfully retrieved." %}

```json
[
    {
        "id": 41,
        "name": "Testing 1",
        "domain": "testing1.getafile.online",
        "created_at": "2024-04-09T16:58:59.000+10:00",
        "updated_at": "2024-04-09T16:58:59.000+10:00",
        "team_id": 8,
        "logo": null,
        "favicon": null,
        "google_analytics_id_consent": 0,
        "google_analytics_id": null,
        "google_analytics_id_secret": null,
        "domaincustom": [
            {
                "id": 4,
                "domain_id": 41,
                "user_id": 1,
                "custom_domain": "testing1.example.com",
                "resolved": 0,
                "setup": 0,
                "errors": null,
                "created_at": "2024-04-09T16:58:59.000+10:00",
                "updated_at": "2024-04-09T16:58:59.000+10:00"
            },
            {
                "id": 8,
                "domain_id": 41,
                "user_id": 1,
                "custom_domain": "testing2.example.com",
                "resolved": 0,
                "setup": 0,
                "errors": null,
                "created_at": "2024-04-09T17:26:39.000+10:00",
                "updated_at": "2024-04-09T17:26:39.000+10:00"
            },
            {
                "id": 9,
                "domain_id": 41,
                "user_id": 1,
                "custom_domain": "testing3.example.com",
                "resolved": 0,
                "setup": 0,
                "errors": null,
                "created_at": "2024-04-09T18:41:36.000+10:00",
                "updated_at": "2024-04-09T18:41:23.000+10:00"
            }
        ],
        "logo_uri": null,
        "favicon_uri": null
    },
    {
        "id": 44,
        "name": "Testing 2",
        "domain": "testing2.getafile.online",
        "created_at": "2024-04-18T13:43:55.000+10:00",
        "updated_at": "2024-04-18T14:29:17.000+10:00",
        "team_id": 8,
        "logo": null,
        "favicon": null,
        "google_analytics_id_consent": 0,
        "google_analytics_id": null,
        "google_analytics_id_secret": null,
        "domaincustom": [
            {
                "id": 12,
                "domain_id": 44,
                "user_id": 1,
                "custom_domain": "testing1.example2.com",
                "resolved": 0,
                "setup": 0,
                "errors": null,
                "created_at": "2024-04-18T13:43:55.000+10:00",
                "updated_at": "2024-04-18T13:43:55.000+10:00"
            }
        ],
        "logo_uri": null,
        "favicon_uri": null
    },
    {
        "id": 46,
        "name": "Testing 3",
        "domain": "testing3.getafile.online",
        "created_at": "2024-04-18T13:56:07.000+10:00",
        "updated_at": "2024-04-18T14:29:24.000+10:00",
        "team_id": 8,
        "logo": null,
        "favicon": null,
        "google_analytics_id_consent": 0,
        "google_analytics_id": null,
        "google_analytics_id_secret": null,
        "domaincustom": [],
        "logo_uri": null,
        "favicon_uri": null
    }
]
```

{% endtab %}
{% endtabs %}


# Create a Domain

Create a new file serving Domain under your account.

**Please note:** Offensive domain names will be replaced with \*\*\*\*

<mark style="color:green;">`POST`</mark> `https://{region}.getafile.io/api/v1/teams/:team_id/domain`

This endpoint allows you to create a new Domain.

#### Path Parameters

| Name     | Type   | Description    |
| -------- | ------ | -------------- |
| team\_id | number | ID of the team |

#### Request Body

| Name                                                             | Type   | Description                                                                                       |
| ---------------------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------- |
| domain<mark style="color:red;">\*</mark>                         | string | The Domain you wish to use: eg test.getafile.online                                               |
| name<mark style="color:red;">\*</mark>                           | string | Reference name for the Domain                                                                     |
| google\_analytics\_id\_consent<mark style="color:red;">\*</mark> | number | <p>Specify if this is your own domain, or a subdomain of getafile.online<br>1 = Yes<br>0 = No</p> |
| google\_analytics\_id                                            | string | The google analytics ID tied to the domain (required if google\_analytics\_id\_consent = 0)       |
| google\_analytics\_id\_secret                                    | string | The google analytics secret tied to the domain (required if google\_analytics\_id\_consent = 0)   |
| domaincustom                                                     | array  | An array of CustomDomain objects. See example request payload                                     |

{% tabs %}
{% tab title="201 Domain successfully created." %}

```json
{
    "name": "Testing",
    "domain": "testing.getafile.online",
    "google_analytics_id_consent": 0,
    "user_id": 1,
    "team_id": "8",
    "active": 1,
    "created_at": "2024-04-18T13:43:55.088+10:00",
    "updated_at": "2024-04-18T13:43:55.089+10:00",
    "id": 1,
    "domaincustom": [
        {
            "id": 1,
            "domain_id": 1,
            "custom_domain": "test.example.com",
            "resolved": 0,
            "setup": 0
        }
    ],
    "logo_uri": null,
    "favicon_uri": null
}
```

{% endtab %}

{% tab title="400 Error with JSON payload." %}

```json
{
    "errors": [
        {
            "message": "That domain is already in use",
            "rule": "domainCheck",
            "field": "domain"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

#### Example Request

```json
{
    "name": "Testing",
    "domain": "testing",
    "domaincustom": [
        {
            "custom_domain": "test.example.com"
        }
    ],
    "google_analytics_id_consent": 0
}
```


# Update a Domain

Update a Domain.

**Please note:** Offensive domain names will be replaced with \*\*\*\*

<mark style="color:orange;">`PUT`</mark> `https://{region}.getafile.io/api/v1/teams/:team_id/domain/:id`

This endpoint allows you to update a Domain.

#### Path Parameters

| Name | Type    | Description       |
| ---- | ------- | ----------------- |
| id   | integer | ID of the Domain. |

#### Request Body

| Name                                                             | Type   | Description                                                                                       |
| ---------------------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------- |
| domain<mark style="color:red;">\*</mark>                         | string | The Domain you wish to use: eg test.getafile.online                                               |
| name<mark style="color:red;">\*</mark>                           | string | Reference name for the Domain                                                                     |
| google\_analytics\_id\_consent<mark style="color:red;">\*</mark> | number | <p>Specify if this is your own domain, or a subdomain of getafile.online<br>1 = Yes<br>0 = No</p> |
| google\_analytics\_id                                            | string | The google analytics ID tied to the domain (required if google\_analytics\_id\_consent = 0)       |
| google\_analytics\_id\_secret                                    | string | The google analytics secret tied to the domain (required if google\_analytics\_id\_consent = 0)   |

{% tabs %}
{% tab title="200 Domain successfully updated." %}

```
{
    "active": 1,
    "name": "Testing",
    "domain": "testing",
    "google_analytics_id_consent": 0,
    "google_analytics_id": null,
    "google_analytics_id_secret": null
}
```

{% endtab %}

{% tab title="404 Could not find a Domain matching this query." %}

```
{    "message": "Ain't no domain like that."}
```

{% endtab %}
{% endtabs %}

#### Example Request

```json
{
    "active": 1,
    "name": "Testing",
    "domain": "testing",
    "google_analytics_id_consent": 0,
    "google_analytics_id": null,
    "google_analytics_id_secret": null
}
```


# List Custom Domains

List all the custom domains that you have access to.

<mark style="color:blue;">`GET`</mark> `https://{region}.getafile.io/api/v1/teams/:team_id/domainscustom`

This endpoint lets you get the list of custom Domains you can access.

The "resolved" field refers to whether or not the domain is currently resolving to Getafile's CNAME record. 1 = Yes, 0 = No

The "resolved" field indicates whether the domain is set up and serving. 1 = Yes, 0 = No

#### Path Parameters

<table><thead><tr><th>Name</th><th width="246">Type</th><th>Description</th></tr></thead><tbody><tr><td>team_id<mark style="color:red;">*</mark></td><td>number</td><td>ID of the team</td></tr></tbody></table>

{% tabs %}
{% tab title="200 Custom Domains successfully retrieved." %}

```json
[
    {
        "id": 9,
        "custom_domain": "testing.example.com",
        "resolved": 0,
        "setup": 0,
        "errors": null,
        "created_at": "2024-04-09T18:41:36.000+10:00",
        "updated_at": "2024-04-09T18:41:23.000+10:00"
    },
    {
        "id": 4,
        "custom_domain": "testing2.example.com",
        "resolved": 1,
        "setup": 1,
        "errors": null,
        "created_at": "2024-04-09T16:58:59.000+10:00",
        "updated_at": "2024-04-09T16:58:59.000+10:00"
    },
    {
        "id": 12,
        "custom_domain": "testing3.example.com",
        "resolved": 1,
        "setup": 1,
        "errors": null,        
        "created_at": "2024-04-18T13:43:55.000+10:00",
        "updated_at": "2024-04-18T13:43:55.000+10:00"
    }    
]
```

{% endtab %}
{% endtabs %}


# Delete a Custom Domain

Delete a Custom Domain.

<mark style="color:red;">`DELETE`</mark> `https://{region}.getafile.io/api/v1/teams/:team_id/domaincustom/:domain_id/:id`

This endpoint allows you to delete a Custom Domain.

**Path Parameters**

<table><thead><tr><th>Name</th><th width="246">Type</th><th>Description</th></tr></thead><tbody><tr><td>team_id<mark style="color:red;">*</mark></td><td>number</td><td>ID of the team</td></tr><tr><td>domain_id<mark style="color:red;">*</mark></td><td>number</td><td>ID of the domain the custom domain belongs to</td></tr><tr><td>id<mark style="color:red;">*</mark></td><td>number</td><td>ID of the custom domain</td></tr></tbody></table>

{% tabs %}
{% tab title="204 Custom Domain successfully deleted." %}

```
```

{% endtab %}

{% tab title="404 Could not find a Custom Domain matching this query." %}

```
{    "message": "Ain't no domain like that."}
```

{% endtab %}
{% endtabs %}


# Get a Custom Domain

Delete a Custom Domain.

<mark style="color:green;">`GET`</mark> `https://{region}.getafile.io/api/v1/teams/:team_id/domaincustom/:domain_id/:id`

This endpoint allows you to delete a Custom Domain.

**Path Parameters**

<table><thead><tr><th>Name</th><th width="246">Type</th><th>Description</th></tr></thead><tbody><tr><td>team_id<mark style="color:red;">*</mark></td><td>number</td><td>ID of the team</td></tr><tr><td>domain_id<mark style="color:red;">*</mark></td><td>number</td><td>ID of the domain this custom domain is tied to</td></tr><tr><td>id<mark style="color:red;">*</mark></td><td>number</td><td>ID of the custom domain</td></tr></tbody></table>

{% tabs %}
{% tab title="204 Custom Domain successfully deleted." %}

```
```

{% endtab %}

{% tab title="404 Could not find a Custom Domain matching this query." %}

```
{    "message": "Ain't no domain like that."}
```

{% endtab %}
{% endtabs %}


# Get File Paths

Retrieve the File Path structure for a domain in your account.

<mark style="color:blue;">`GET`</mark> `https://{region}.getafile.io/api/v1/teams/:team_id/filepath/:domain_id`

This endpoint allows you to get the File Path structure for a domain.

#### Path Parameters

| Name       | Type    | Description      |
| ---------- | ------- | ---------------- |
| domain\_id | integer | ID of the Domain |
| team\_id   | integer | ID of the Team   |

{% tabs %}
{% tab title="200 File Paths successfully retrieved." %}

```json
[
    {
        "id": 70,
        "user_id": 1,
        "domain_id": 26,
        "parent_id": null,
        "name": "test",
        "slug": "test",
        "created_at": "2024-03-03T17:14:37.000+10:00",
        "updated_at": "2024-03-03T17:14:37.000+10:00",
        "meta": {
            "fullurl": "test",
            "label": "test (1)",
            "fullname": "test"
        }
    }
]
```

{% endtab %}
{% endtabs %}


# Create a File Path

Create a File Path in a domain.

**Please note:** Offensive file path names will be replaced with \*\*\*\*

<mark style="color:green;">`POST`</mark> `https://{region}.getafile.io/api/v1/teams/:team_id/filepath`

This endpoint allows you to create a File Path.

#### Path Parameters

| Name                                       | Type    | Description    |
| ------------------------------------------ | ------- | -------------- |
| team\_id<mark style="color:red;">\*</mark> | integer | ID of the Team |

#### Request Body

| Name                                         | Type    | Description                |
| -------------------------------------------- | ------- | -------------------------- |
| name<mark style="color:red;">\*</mark>       | string  | File Path name             |
| domain\_id<mark style="color:red;">\*</mark> | integer | ID of the Domain           |
| parent\_id                                   | integer | ID of the Parent File path |

{% tabs %}
{% tab title="201 File Path successfully created." %}

```json
{
    "name": "Testing",
    "domain_id": 1,
    "parent_id": null,
    "user_id": 1,
    "slug": "testing",
    "created_at": "2024-03-12T09:31:32.381+10:00",
    "updated_at": "2024-03-12T09:31:32.382+10:00",
    "id": 76,
    "meta": {}
}
```

{% endtab %}

{% tab title="400 There was an issue with the JSON payload." %}

```
[
    {
        "message": "This path name is already in use",
        "field": "name",
        "validation": "existsFilePath"
    }
]
```

{% endtab %}
{% endtabs %}


# Update a File Path

Update a File Category for a Domain in your account.

**Please note:** Offensive file category names will be replaced with \*\*\*\*

<mark style="color:orange;">`PUT`</mark> `https://{region}.getafile.io/api/v1/teams/:team_id/filepath/:id`

This endpoint allows you to update a File Category.

#### Path Parameters

| Name                                       | Type    | Description         |
| ------------------------------------------ | ------- | ------------------- |
| id<mark style="color:red;">\*</mark>       | string  | ID of the File Path |
| team\_id<mark style="color:red;">\*</mark> | integer | ID of the Team      |

#### Request Body

| Name                                         | Type    | Description                |
| -------------------------------------------- | ------- | -------------------------- |
| name<mark style="color:red;">\*</mark>       | string  | File Path name             |
| domain\_id<mark style="color:red;">\*</mark> | integer | Domain ID                  |
| parent\_id                                   | integer | ID of the parent File Path |

{% tabs %}
{% tab title="200 Cake successfully retrieved." %}

```json
{
    "id": 76,
    "user_id": 1,
    "domain_id": 26,
    "parent_id": null,
    "name": "Testing Test",
    "slug": "testing-test",
    "created_at": "2024-03-12T09:31:32.000+10:00",
    "updated_at": "2024-03-12T09:40:43.000+10:00",
    "meta": {
        "fullurl": "testing-test",
        "label": "testing-test (0)",
        "fullname": "Testing Test"
    }
}
```

{% endtab %}

{% tab title="404 Could not find a cake matching this query." %}

```
{    "message": "Ain't no cake like that."}
```

{% endtab %}
{% endtabs %}


# Delete a File Path

Delete a File Path for a domain in your account.

<mark style="color:red;">`DELETE`</mark> `https://{region}.getafile.io/api/v1/teams/:team_id/filepath/:id`

This endpoint allows you to get delete a File Path.

#### Path Parameters

| Name | Type   | Description         |
| ---- | ------ | ------------------- |
| id   | string | ID of the File Path |

{% tabs %}
{% tab title="204 File Category successfully deleted." %}

```
```

{% endtab %}
{% endtabs %}


# Get Domain Files

Get a list of files for a domain in your account.

<mark style="color:green;">`GET`</mark>`https://{region}.getafile.io/api/v1/teams/:team_id/file/index/:domain_id`

#### Path Parameters

| Name                                         | Type    | Description      |
| -------------------------------------------- | ------- | ---------------- |
| domain\_id<mark style="color:red;">\*</mark> | integer | ID of the Domain |
| team\_id<mark style="color:red;">\*</mark>   | integer | ID of the Team   |

#### Query Params

| Name    | Type   | Description                                                      |
| ------- | ------ | ---------------------------------------------------------------- |
| type    | string | Only these types of files: eg. document, image, css etc          |
| trashed | number | <p>1 - Show only trashed files<br>0 - Show only active files</p> |

{% tabs %}
{% tab title="200 Files successfully retrieved." %}

<pre class="language-json"><code class="lang-json">[
    {
        "id": 93,
        "user_id": 1,
        "domain_id": 26,
        "name": "test",
        "path_id": 70,
        "url": "test",
        "fullurl": "/test/test",
        "published": 1,
        "type": "document",
        "password": null,
        "ips": null,
        "description": null,
        "external_id": null,
        "created_at": "2024-03-03T11:39:04.000+10:00",
        "updated_at": "2024-03-06T09:06:37.000+10:00",
        "download_only": 0,
        "team_id": 8,
        "meta": {
            "discoverable": 0,
            "uri": {
                "getafile": "https://testing.getafile.online/test/test",
                "custom": [
                    "https://mycustom.domain.com/test/test"
                ]
            }
        },
        "filereferrer": [
            {
                "id": 28,
                "user_id": 1,
                "team_id": 8,
                "hostname": "example.canserve.com",
                "created_at": "2024-12-19T13:23:15.000+10:00",
                "updated_at": "2024-12-19T13:23:15.000+10:00"
            }
        ],
<strong>        "currentversion": {
</strong>            "id": 263,
            "file_id": 131,
            "user_id": 1,
            "filename": "6779-Test.png",
            "active": 1,
            "verified": 1,
            "stats": {
                "sizeHuman": "285.2 KB",
                "size": 285210,
                "ext": ".png",
                "dimensions": {
                    "height": 1024,
                    "width": 1024
                }
            },
            "created_at": "2024-04-23T16:29:29.000+10:00",
            "updated_at": "2024-04-23T16:29:29.000+10:00",
            "size": 285210,
            "version_name": "Version 1.0",
            "version_description": "New version requested by customer",
        }
    }
]
</code></pre>

{% endtab %}
{% endtabs %}


# Get a File

Get a File in your account.

<mark style="color:blue;">`GET`</mark> `https://{region}.getafile.io/api/v1/teams/:team_id/file/:id`

This endpoint allows you to get a File entry in your account.

#### Path Parameters

| Name                                       | Type    | Description    |
| ------------------------------------------ | ------- | -------------- |
| id<mark style="color:red;">\*</mark>       | integer | ID of the File |
| team\_id<mark style="color:red;">\*</mark> | integer | ID of the Team |

{% tabs %}
{% tab title="200 File successfully retrieved." %}

```json
{
    "id": 1,
    "user_id": 1,
    "domain_id": 8,
    "name": "Test",
    "path_id": null,
    "tags": null,
    "url": "test",
    "fullurl": "test",
    "published": 1,
    "type": "document",
    "password": null,
    "ips": null,
    "external_id": null,
    "created_at": "2020-10-03T01:55:48.000Z",
    "updated_at": "2020-10-03T06:36:13.000Z",
    "deleted_at": null,
    "filereferrer": [
            {
                "id": 28,
                "user_id": 1,
                "team_id": 8,
                "hostname": "example.canserve.com",
                "created_at": "2024-12-19T13:23:15.000+10:00",
                "updated_at": "2024-12-19T13:23:15.000+10:00"
            }
    ],
    "filepath": {
            "id": 88,
            "name": "deep",
            "slug": "deep",
            "parent_id": 87,
            "meta": {
                "label": "deep (1)",
                "fullname": "Test -> emails -> default",
                "fullurl": "test/emails/default"
            }
    },
    "versions": [
        {
            "id": 1,
            "file_id": 1,
            "user_id": 1,
            "filename": "Test_2.pdf",
            "active": 1,
            "verified": 1,
            "created_at": "2020-10-03T02:02:12.000Z",
            "updated_at": "2020-10-03T22:36:35.000Z",
            "thumbnail": "/api/fileversion/thumbnail/98",
            "url": "/api/fileversion/98",
            "version_name": "Version 2.0",
            "version_description": "New version requested by customer"
        },
        {
            "id": 2,
            "file_id": 1,
            "user_id": 1,
            "filename": "TestVersion.pdf",
            "active": 0,
            "verified": 0,
            "created_at": "2020-10-04T23:22:40.000Z",
            "updated_at": "2020-10-04T23:22:40.000Z",
            "thumbnail": "/api/fileversion/thumbnail/111",
            "url": "/api/fileversion/111",
            "version_name": "Version 1.0",
            "version_description": "New version requested by customer"
        }
    ],
    "meta": {
        "uri": {
            "getafile": "https://testing.getafile.online/test",
            "custom": [
                "https://mycustom.domain.com/test",
                "https://mycustom.domain2.com/test"
            ]
        }
    }
}
```

{% endtab %}

{% tab title="404 Could not find a File matching this query." %}

```
```

{% endtab %}
{% endtabs %}


# Create a File

**Please note:** If you include "filename" and "fileversion" elements, a new version will be created and served.

<mark style="color:green;">`POST`</mark> `https://{region}.getafile.io/api/v1/teams/:team_id/file`

This endpoint allows you to create a file.

#### Path Parameters

<table><thead><tr><th width="301">Name</th><th width="151">Type</th><th>Description</th></tr></thead><tbody><tr><td>team_id<mark style="color:red;">*</mark></td><td>integer</td><td>ID of the team</td></tr></tbody></table>

#### Request Body

<table><thead><tr><th>Name</th><th width="150">Type</th><th>Description</th></tr></thead><tbody><tr><td>description<mark style="color:red;">*</mark></td><td>string</td><td>Description of the file for social sharing</td></tr><tr><td>published<mark style="color:red;">*</mark></td><td>integer</td><td>Published: 0 or 1</td></tr><tr><td>type<mark style="color:red;">*</mark></td><td>string</td><td>Type of File (image, document, video)</td></tr><tr><td>name<mark style="color:red;">*</mark></td><td>string</td><td>Reference name for the File</td></tr><tr><td>url<mark style="color:red;">*</mark></td><td>string</td><td>URL where the FIle can be accessed</td></tr><tr><td>domain_id<mark style="color:red;">*</mark></td><td>string</td><td>ID of the Domain</td></tr><tr><td>path_id<mark style="color:red;">*</mark></td><td>integer</td><td>ID of the File Path</td></tr><tr><td>fileversion</td><td>string</td><td>Base64 file data for the first version</td></tr><tr><td>fileversion_url</td><td>string</td><td>URL of a file to use as the first version. It must be a publicly accessible URL.</td></tr><tr><td>filename</td><td>string</td><td>Name of the file for the first version</td></tr><tr><td>ips</td><td>string</td><td>Restrict access to the File to IP addresses: eg. xxx.xx.xxx.xxx, xx.xxx.xx.x</td></tr><tr><td>password</td><td>string</td><td>Password protect the File</td></tr><tr><td>download_only<mark style="color:red;">*</mark></td><td>integer</td><td>This forces the file to always be downloaded: 0 or 1</td></tr><tr><td>domaincustom<mark style="color:red;">*</mark></td><td>array</td><td>An array of custom domain IDs</td></tr><tr><td>tags<mark style="color:red;">*</mark></td><td>array</td><td>An array of tags to attach to the file</td></tr><tr><td>optimizer_enabled<mark style="color:red;">*</mark></td><td>number</td><td>Optimize file versions (only applies to file type "image"): 0 or 1</td></tr><tr><td>optimizer_quality<mark style="color:red;">*</mark></td><td>number</td><td>Desired image quality after optimizing: Min 10, Max 100</td></tr><tr><td>serving_type<mark style="color:red;">*</mark></td><td>string</td><td>The type of content to serve.<br>Values:<br><strong>file:</strong> Uploaded files<br><strong>content:</strong> File content will be managed in the Getafile code editor (Javascript / CSS only).</td></tr><tr><td>content</td><td>string</td><td>The Javascript / CSS content of the first version when the serving type is <strong>content</strong></td></tr><tr><td>external_id</td><td>string</td><td>External ID from another platform for reference</td></tr><tr><td>filereferrer</td><td>array</td><td>An array of <a href="/referrers/list-referrers">referrer</a> IDs</td></tr></tbody></table>

{% tabs %}
{% tab title="201 File created successfully." %}

```json
{
    "id": 64,
    "user_id": 1,
    "domain_id": 8,
    "name": "Test",
    "path_id": null,
    "tags": null,
    "url": "test",
    "fullurl": "test",
    "published": 1,
    "type": "document",
    "discoverable": 0,
    "password": null,
    "ips": null,
    "external_id": null,
    "created_at": "2020-10-04T06:01:11.000Z",
    "updated_at": "2020-10-04T06:01:11.000Z",
    "uri": "https://sandbox-getafile-online.getafile.online/test",
    "statusping": 1,
    "statusping_config": {
      "retries": 3,
      "retries_pause": 3,
      "emails": ["test@example.com"],
    },
    "serving_type": "file",
    "content": null
}
```

{% endtab %}

{% tab title="400 There was an issue with the JSON payload." %}

```
[
    {
        "message": "That URL is already in use for this domain",
        "field": "url",
        "validation": "checkFileUrl"
    }
]
```

{% endtab %}
{% endtabs %}


# Update a File

Update a File in your account.

<mark style="color:orange;">`PUT`</mark> `https://{region}.getafile.io/api/v1/teams/:team_id/file/:id`

This endpoint allows you to update a File in your account.

#### Path Parameters

<table><thead><tr><th width="249">Name</th><th width="122">Type</th><th>Description</th></tr></thead><tbody><tr><td>id<mark style="color:red;">*</mark></td><td>integer</td><td>ID of the File</td></tr><tr><td>team_id<mark style="color:red;">*</mark></td><td>integer</td><td>ID of the Team</td></tr></tbody></table>

#### Request Body

<table><thead><tr><th width="251">Name</th><th width="125">Type</th><th>Description</th></tr></thead><tbody><tr><td>description<mark style="color:red;">*</mark></td><td>string</td><td>Description of the file for social sharing</td></tr><tr><td>published<mark style="color:red;">*</mark></td><td>string</td><td>Published: 1 or 0</td></tr><tr><td>type<mark style="color:red;">*</mark></td><td>string</td><td>Type of File (image, document, video)</td></tr><tr><td>name<mark style="color:red;">*</mark></td><td>string</td><td>Reference name for the File</td></tr><tr><td>url<mark style="color:red;">*</mark></td><td>string</td><td>URL where the File can be accessed</td></tr><tr><td>domain_id<mark style="color:red;">*</mark></td><td>integer</td><td>ID of the Domain</td></tr><tr><td>path_id</td><td>string</td><td>ID of the File Path</td></tr><tr><td>ips</td><td>string</td><td>Restrict access to the File to IP addresses: eg. xx.xxx.xx.xx, xxx.xx.xxx.x</td></tr><tr><td>password</td><td>string</td><td>Password protect the File</td></tr><tr><td>download_only<mark style="color:red;">*</mark></td><td>integer</td><td>Download only: 1 or 0</td></tr><tr><td>external_id</td><td>string</td><td>External ID from another platform for reference</td></tr><tr><td>filereferrer</td><td>array</td><td>An array of <a href="/referrers/list-referrers">referrer</a> IDs</td></tr></tbody></table>

{% tabs %}
{% tab title="200 File successfully updated." %}

```json
{
    "id": 64,
    "user_id": 1,
    "domain_id": 8,
    "name": "Test",
    "path_id": null,
    "tags": null,
    "url": "test",
    "fullurl": "test",
    "published": 1,
    "type": "document",
    "discoverable": 0,
    "password": null,
    "ips": null,
    "external_id": null,
    "created_at": "2020-10-04T06:01:11.000Z",
    "updated_at": "2020-10-04T06:01:11.000Z",
    "uri": "https://sandbox-getafile-online.getafile.online/test",
    "statusping": 1,
    "statusping_config": {
      "retries": 3,
      "retries_pause": 3,
      "emails": ["test@example.com"],
    },
    "serving_type": "file",
    "content": null
}
```

{% endtab %}

{% tab title="400 There was an issue with the JSON payload." %}

```
[
    {
        "message": "That URL is already in use for this domain",
        "field": "url",
        "validation": "checkFileUrl"
    }
]
```

{% endtab %}
{% endtabs %}


# Delete a File

Delete a file from your account.

<mark style="color:red;">`DELETE`</mark> `https://{region}.getafile.io/api/v1/teams/:team_id/file/:id`

This endpoint allows you to delete a File in your account. Files deleted within the past 30 days can be  restored using the Update a File endpoint.

#### Path Parameters

| Name                                       | Type    | Description    |
| ------------------------------------------ | ------- | -------------- |
| id<mark style="color:red;">\*</mark>       | integer | ID of the File |
| team\_id<mark style="color:red;">\*</mark> | integer | ID of the Team |

{% tabs %}
{% tab title="204 File successfully deleted." %}

```
```

{% endtab %}

{% tab title="404 Could not find a File matching this query." %}

```
```

{% endtab %}
{% endtabs %}


# Restore a File

Restore a deleted file to your account.

<mark style="color:red;">`PUT`</mark> `https://{region}.getafile.io/api/v1/teams/:team_id/file/:id/restore`

This endpoint allows you to restore a deleted  File in your account.&#x20;

#### Path Parameters

| Name                                       | Type    | Description    |
| ------------------------------------------ | ------- | -------------- |
| id<mark style="color:red;">\*</mark>       | integer | ID of the File |
| team\_id<mark style="color:red;">\*</mark> | integer | ID of the Team |

{% tabs %}
{% tab title="200 File successfully restored." %}

```
```

{% endtab %}

{% tab title="404 Could not find a File matching this query." %}

```
```

{% endtab %}
{% endtabs %}


# Permanently Delete a File

Delete a file from your account.

<mark style="color:red;">`DELETE`</mark> `https://{region}.getafile.io/api/v1/teams/:team_id/file/:id/permanent`   &#x20;

This endpoint allows you to permanently delete a file, and the action cannot be reversed.

#### Path Parameters

| Name                                       | Type    | Description    |
| ------------------------------------------ | ------- | -------------- |
| id<mark style="color:red;">\*</mark>       | integer | ID of the File |
| team\_id<mark style="color:red;">\*</mark> | integer | ID of the Team |

{% tabs %}
{% tab title="204 File successfully deleted." %}

```
```

{% endtab %}

{% tab title="404 Could not find a File matching this query." %}

```
```

{% endtab %}
{% endtabs %}


# List File Versions

Retreive a list of File Versions for a File.

<mark style="color:blue;">`GET`</mark> `https://{region}.getafile.io/api/v1/teams/:team_id/fileversion/index/:file_id`

This endpoint allows you to get the Versions for a File.

#### Path Parameters

| Name                                       | Type    | Description    |
| ------------------------------------------ | ------- | -------------- |
| file\_id<mark style="color:red;">\*</mark> | integer | ID of the File |
| team\_id<mark style="color:red;">\*</mark> | integer | ID of the Team |

{% tabs %}
{% tab title="200 File Versions successfully retrieved." %}

```json
[
    {
        "id": 1,
        "file_id": 56,
        "user_id": 1,
        "filename": "TestVersion.pdf",
        "active": 0,
        "verified": 0,
        "created_at": "2020-10-04T23:22:40.000Z",
        "updated_at": "2020-10-04T23:22:40.000Z",
        "thumbnail": "/api/fileversion/thumbnail/111",
        "url": "/api/fileversion/111"
    },
    {
        "id": 2,
        "file_id": 56,
        "user_id": 1,
        "filename": "Test_2.pdf",
        "active": 1,
        "verified": 1,
        "created_at": "2020-10-03T02:02:12.000Z",
        "updated_at": "2020-10-03T22:36:35.000Z",
        "thumbnail": "/api/fileversion/thumbnail/98",
        "url": "/api/fileversion/98",
        "content": null,
        "content_minified": null
    }
]
```

{% endtab %}

{% tab title="404 Could not find a File matching this query." %}

```
```

{% endtab %}
{% endtabs %}


# Get a File Version

Get a File Version in your account.

<mark style="color:blue;">`GET`</mark> `https://{region}.getafile.io/api/v1/teams/:team_id/fileversion/:file_version_id`

This endpoint allows you to get a File Version.

#### Path Parameters

| Name                                                | Type    | Description            |
| --------------------------------------------------- | ------- | ---------------------- |
| file\_version\_id<mark style="color:red;">\*</mark> | integer | ID of the File Version |
| team\_id<mark style="color:red;">\*</mark>          | integer | ID of the Team         |

{% tabs %}
{% tab title="200 File Version successfully retrieved." %}

```json
{
    "id": 1,
    "file_id": 1,
    "user_id": 1,
    "filename": "Version123.pdf",
    "active": 1,
    "verified": 1,
    "stats": null,
    "created_at": "2024-03-13T09:04:51.000+10:00",
    "updated_at": "2024-03-13T09:04:51.000+10:00",
    "meta": {},
    "content": null,
    "content_minified": null
}
```

{% endtab %}

{% tab title="404 Could not find a File Version matching this query." %}

```
```

{% endtab %}
{% endtabs %}


# Create a File Version

Add a new File Version to a File

**Please note:** All new File Versions will be content checked for Adult, Violent and Spoofing content.

<mark style="color:green;">`POST`</mark> `https://{region}.getafile.io/api/v1/teams/:team_id/fileversion`

This endpoint allows you to create a new File Version.

#### Request Body

<table><thead><tr><th width="243">Name</th><th width="140">Type</th><th>Description</th></tr></thead><tbody><tr><td>file_id</td><td>integer</td><td>ID of the File</td></tr><tr><td>filename</td><td>string</td><td>Name of the file you are uploading</td></tr><tr><td>fileversion</td><td>string</td><td>Base64 encoded file data</td></tr><tr><td>version_name</td><td>string</td><td>Name of the version</td></tr><tr><td>version_description</td><td>string</td><td>Description of the version</td></tr><tr><td>active</td><td>integer</td><td>1 for active, 0 for inactive<br><em>*Please note: Files with the serving type of "content" will always be made active upon version creation</em></td></tr><tr><td>content</td><td>string</td><td>Code content of the version when the file serving type is <strong>content</strong></td></tr></tbody></table>

{% tabs %}
{% tab title="201 File Version created successfully." %}

```json
{
    "id": 1,
    "file_id": 5,
    "user_id": 1,
    "filename": "Testing-1.png",
    "active": 1,
    "verified": 1,
    "stats": {
        "sizeHuman": "285.2 KB",
        "size": 285210,
        "ext": ".png",
        "dimensions": {
            "height": 1024,
            "width": 1024
        }
    },
    "created_at": "2024-04-18T19:16:05.000+10:00",
    "updated_at": "2024-04-18T19:16:05.000+10:00",
    "size": 285210,
    "meta": {},
    "version_name": "Version 1.0",
    "version_description": "Version description",
    "content": null
}
```

{% endtab %}

{% tab title="400 There was an issue with the JSON payload. " %}

```
[
    {
        "message": "You must include a valid file type",
        "field": "filename",
        "validation": "checkFileVersionType"
    }
]
```

{% endtab %}
{% endtabs %}


# Make Active

Make a File Version active.

**Please note:** Only verified file versions can be made active.

<mark style="color:orange;">`PUT`</mark> `https://{region}.getafile.io/api/v1/teams/:team_id/fileversion/makeactive/:file_version_id`

This endpoint allows you to get to switch the active File Version for a File.

#### Path Parameters

| Name                                                | Type    | Description                           |
| --------------------------------------------------- | ------- | ------------------------------------- |
| file\_version\_id<mark style="color:red;">\*</mark> | string  | ID of the File Version to make active |
| team\_id<mark style="color:red;">\*</mark>          | integer | ID of the Team                        |

{% tabs %}
{% tab title="200 Request successfull." %}

```
{    "name": "Cake's name",    "recipe": "Cake's recipe name",    "cake": "Binary cake"}
```

{% endtab %}

{% tab title="404 Could not find a cake matching this query." %}

```
{    "message": "Ain't no cake like that."}
```

{% endtab %}
{% endtabs %}


# Delete a File Version

Delete a File Version from a File in your account.

<mark style="color:red;">`DELETE`</mark> `https://{region}.getafile.io/api/v1/fileversion/:id`

This endpoint allows you to get free cakes.

#### Path Parameters

| Name | Type    | Description                       |
| ---- | ------- | --------------------------------- |
| id   | integer | ID of the File Version to delete. |

{% tabs %}
{% tab title="204 File Version successfully deleted." %}

```
```

{% endtab %}

{% tab title="404 Could not find a File Version matching this query." %}

```
```

{% endtab %}
{% endtabs %}


# List Referrers

Get a list of referrer domains added by your Team.

<mark style="color:green;">`GET`</mark>`https://{region}.getafile.io/api/v1/teams/:team_id/referrers`

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Response**

{% tabs %}
{% tab title="200" %}

```json
[
    {
        "id": 28,
        "user_id": 1,
        "team_id": 8,
        "hostname": "example.canserve.com",
        "created_at": "2024-12-19T13:23:15.000+10:00",
        "updated_at": "2024-12-19T13:23:15.000+10:00"
    },
    {
        "id": 24,
        "user_id": 1,
        "team_id": 8,
        "hostname": "example.doserve.com",
        "created_at": "2024-12-19T12:48:58.000+10:00",
        "updated_at": "2024-12-19T12:48:58.000+10:00"
    }
]
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


