# createExternalFile

```graphql
mutation CreateExternalFile($projectReference: String!, $provider: ExternalFileProvider!, $input: CreateExternalFileInput!) {
  createExternalFile(projectReference: $projectReference, provider: $provider, input: $input) {
    id
    provider
    name
    path
    mimeType
    sizeBytes
    kind
    parentId
    modifiedAt
    etag
    thumbnailUrl
    webUrl
  }
}
```

Create external file. Requires project.integrations.connect.

## Arguments

| Name                    | Type                        | Required | Description                                                                                                                                                                                                          |
| ----------------------- | --------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `projectReference`      | String!                     | Yes      | Project ID or slug. Requires project.integrations.connect through the caller's own personal provider connection.                                                                                                     |
| `provider`              | ExternalFileProvider!       | Yes      | Storage provider accessed through the caller's own personal connection. A human caller is required; agent, run, and service-account credentials are refused. One of `onedrive`, `sharepoint`, `drive`.               |
| `input`                 | CreateExternalFileInput!    | Yes      |                                                                                                                                                                                                                      |
| `input.folderId`        | String!                     | Yes      | Parent folder item ID or root.                                                                                                                                                                                       |
| `input.name`            | String!                     | Yes      | Creates a new file without replacing an existing one. OneDrive and SharePoint return conflict for an existing name; Google Drive creates a new item with the same name. File name, 1-255 characters without a slash. |
| `input.content`         | String!                     | Yes      | File content, at most 10,000,000 characters as sent.                                                                                                                                                                 |
| `input.contentEncoding` | ExternalFileContentEncoding |          | utf8 (default) or base64. One of `utf8`, `base64`.                                                                                                                                                                   |
| `input.mimeType`        | String                      |          | MIME type; derived from the name when omitted.                                                                                                                                                                       |
| `input.idempotencyKey`  | String                      |          | 1-128 characters without whitespace. A retry with the same key and input within 24 hours returns the first file instead of creating another.                                                                         |

## Variables

```json
{
  "projectReference": "string",
  "provider": "onedrive",
  "input": {
    "folderId": "string",
    "name": "string",
    "content": "string"
  }
}
```

## Responses

| Status | Description                                          |
| ------ | ---------------------------------------------------- |
| 200    | The ExternalStorageFile! in data.createExternalFile. |

## 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 CreateExternalFile($projectReference: String!, $provider: ExternalFileProvider!, $input: CreateExternalFileInput!) {\n  createExternalFile(projectReference: $projectReference, provider: $provider, input: $input) {\n    id\n    provider\n    name\n    path\n    mimeType\n    sizeBytes\n    kind\n    parentId\n    modifiedAt\n    etag\n    thumbnailUrl\n    webUrl\n  }\n}",
  "variables": {
    "projectReference": "string",
    "provider": "onedrive",
    "input": {
      "folderId": "string",
      "name": "string",
      "content": "string"
    }
  }
}'
```

## Example response

```json
{
  "data": {
    "createExternalFile": {
      "id": "string",
      "provider": "string",
      "name": "string",
      "path": "string",
      "mimeType": "string",
      "sizeBytes": 0,
      "kind": "string",
      "parentId": "string",
      "modifiedAt": "string",
      "etag": "string",
      "thumbnailUrl": "https://example.com",
      "webUrl": "https://example.com"
    }
  }
}
```
