Skip to content

Create a file upload session

client.File.New(ctx, body) (*FileCreateResponse, error)
POST/v1/files

Creates a new file upload session and returns an upload URL.

After uploading the file bytes to uploadUrl, call POST /v1/files/{id}/complete to finalize the upload. Optionally pass purpose to validate MIME type and size constraints at creation time. See File uploads for the full upload flow, supported purposes, and size limits. If you are uploading a meeting transcript, see Uploading meeting transcripts for the follow-up meeting attachment flow.

Required scope: files:create

Rate limit category: Write

ParametersExpand Collapse
body FileNewParams
Filename param.Field[string]

Original filename.

minLength1
maxLength255
MimeType param.Field[string]

MIME type of the file. Must be allowed for the given purpose (if specified).

SizeBytes param.Field[int64]

Expected file size in bytes. Maximum 512 MB.

minimum1
maximum536870912
Purpose param.Field[FileNewParamsPurpose]Optional

Optional validation hint. When provided, the server enforces purpose-specific MIME type and file size constraints. Use meeting_transcript for files that will be attached to a meeting as its transcript. Use meeting_recording for the audio or video of an uploaded meeting recording (MP4, WebM, QuickTime, MP3, M4A, WAV or OGG). Use knowledge_user or knowledge_workspace to stage an upload for the authenticated user or workspace. Completing the upload does not add it to Knowledge; promote it separately through the agent or Knowledge workflow. Use contact_avatar for an image that will be set as a contact photo through the contact $profilePhotoUrl field. Not returned in responses.

const FileNewParamsPurposeMeetingTranscript FileNewParamsPurpose = "meeting_transcript"
const FileNewParamsPurposeMeetingRecording FileNewParamsPurpose = "meeting_recording"
const FileNewParamsPurposeKnowledgeUser FileNewParamsPurpose = "knowledge_user"
const FileNewParamsPurposeKnowledgeWorkspace FileNewParamsPurpose = "knowledge_workspace"
const FileNewParamsPurposeEmailAttachment FileNewParamsPurpose = "email_attachment"
const FileNewParamsPurposeContactAvatar FileNewParamsPurpose = "contact_avatar"
ReturnsExpand Collapse
type FileCreateResponse struct{…}
ID string

Unique identifier for the file.

CompletedAt string

When the file upload was completed.

CreatedAt string

When the file upload session was created.

ExpiresAt string

When the upload session expires. Null once completed, cancelled, or expired.

Filename string

Original filename.

Kind FileCreateResponseKind

Whether the item is a file or a folder. Null when the response was built without that column.

One of the following:
const FileCreateResponseKindFile FileCreateResponseKind = "file"
const FileCreateResponseKindFolder FileCreateResponseKind = "folder"
MimeType string

MIME type of the file.

ModifiedAt string

When the storage last modified this item. Null for a non-storage file, and for a storage item whose modified time has not been stored.

ParentID string

The storage folder this item sits in, or null for a top-level item or a non-storage file.

SizeBytes int64

File size in bytes.

minimum-9007199254740991
maximum9007199254740991
Source FileCreateResponseSource

Where the file came from. googleDrive for a linked Google Drive item, microsoftDrive for a linked OneDrive or SharePoint item. Null for every other file.

One of the following:
const FileCreateResponseSourceGoogleDrive FileCreateResponseSource = "googleDrive"
const FileCreateResponseSourceMicrosoftDrive FileCreateResponseSource = "microsoftDrive"
Status FileCreateResponseStatus

Current upload status of the file.

One of the following:
const FileCreateResponseStatusPending FileCreateResponseStatus = "PENDING"
const FileCreateResponseStatusCompleted FileCreateResponseStatus = "COMPLETED"
const FileCreateResponseStatusCancelled FileCreateResponseStatus = "CANCELLED"
const FileCreateResponseStatusExpired FileCreateResponseStatus = "EXPIRED"
UploadHeaders map[string, string]

Headers to include in the upload request.

UploadURL string

Upload URL. Upload the file bytes directly to this URL.

WebURL string

A link that opens this item in Google Drive, OneDrive or SharePoint. Null for a non-storage file.

Create a file upload session

package main

import (
  "context"
  "fmt"

  "github.com/Lightfld/lightfield-go"
  "github.com/Lightfld/lightfield-go/option"
)

func main() {
  client := githubcomlightfldlightfieldgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  fileCreateResponse, err := client.File.New(context.TODO(), githubcomlightfldlightfieldgo.FileNewParams{
    Filename: "x",
    MimeType: "mimeType",
    SizeBytes: 1,
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", fileCreateResponse.ID)
}
{
  "id": "id",
  "completedAt": "completedAt",
  "createdAt": "createdAt",
  "expiresAt": "expiresAt",
  "filename": "filename",
  "kind": "file",
  "mimeType": "mimeType",
  "modifiedAt": "modifiedAt",
  "parentId": "parentId",
  "sizeBytes": -9007199254740991,
  "source": "googleDrive",
  "status": "PENDING",
  "uploadHeaders": {
    "foo": "string"
  },
  "uploadUrl": "uploadUrl",
  "webUrl": "webUrl"
}
Returns Examples
{
  "id": "id",
  "completedAt": "completedAt",
  "createdAt": "createdAt",
  "expiresAt": "expiresAt",
  "filename": "filename",
  "kind": "file",
  "mimeType": "mimeType",
  "modifiedAt": "modifiedAt",
  "parentId": "parentId",
  "sizeBytes": -9007199254740991,
  "source": "googleDrive",
  "status": "PENDING",
  "uploadHeaders": {
    "foo": "string"
  },
  "uploadUrl": "uploadUrl",
  "webUrl": "webUrl"
}