# importExternalFile

```graphql
mutation ImportExternalFile($input: ExternalStorageImportInput!) {
  importExternalFile(input: $input) {
    upload {
      id
      projectId
      path
      name
      mimeType
      sizeBytes
      visibility
    }
    source {
      provider
      fileId
    }
  }
}
```

Import external file. Requires project.uploads.write.

## Arguments

| Name                     | Type                        | Required | Description                                                                                                                                                                                        |
| ------------------------ | --------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `input`                  | ExternalStorageImportInput! | Yes      |                                                                                                                                                                                                    |
| `input.provider`         | String!                     | Yes      | Storage provider accessed through the caller's own personal connection. A human caller is required; agent, run, and service-account credentials are refused.                                       |
| `input.projectReference` | String                      |          | Project ID or slug. Requires project.uploads.write and destination upload edit permission; quota and plan limits apply. Uses the caller's own personal provider connection.                        |
| `input.fileId`           | String!                     | Yes      |                                                                                                                                                                                                    |
| `input.basePath`         | String                      |          |                                                                                                                                                                                                    |
| `input.folderPath`       | String                      |          | Destination folder inside Uploads; the Uploads root when omitted.                                                                                                                                  |
| `input.timestampPrefix`  | Boolean                     |          |                                                                                                                                                                                                    |
| `input.visibility`       | UploadFolderVisibility      |          | Visibility of the new upload; inherited from the destination when omitted. Setting it needs upload admin access on the destination, and public a paid plan. One of `project`, `public`, `private`. |
| `input.idempotencyKey`   | String                      |          | 1-128 characters without whitespace. A retry with the same key and input within 24 hours returns the first import instead of importing again.                                                      |

## Variables

```json
{
  "input": {
    "provider": "string",
    "fileId": "string"
  }
}
```

## Responses

| Status | Description                                            |
| ------ | ------------------------------------------------------ |
| 200    | The ExternalStorageImport! in data.importExternalFile. |

## Call it

```bash
curl -X POST "https://api.veryfront.com/graphql" \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "query": "mutation ImportExternalFile($input: ExternalStorageImportInput!) {\n  importExternalFile(input: $input) {\n    upload {\n      id\n      projectId\n      path\n      name\n      mimeType\n      sizeBytes\n      visibility\n    }\n    source {\n      provider\n      fileId\n    }\n  }\n}",
  "variables": {
    "input": {
      "provider": "string",
      "fileId": "string"
    }
  }
}'
```

## Example response

```json
{
  "data": {
    "importExternalFile": {
      "upload": {
        "id": "string",
        "projectId": "string",
        "path": "string",
        "name": "string",
        "mimeType": "string",
        "sizeBytes": 0,
        "visibility": "string"
      },
      "source": {
        "provider": "string",
        "fileId": "string"
      }
    }
  }
}
```
