Skip to content

Function: usePitcherApi()

usePitcherApi(options?): object

Check out the returned object documentation for the list of available methods.

Parameters

ParameterType
options?ApiOptions

Returns

object

API

API: LowLevelApi

broadcast()

broadcast: (event) => Promise<any>

Broadcast an event to CatalogIQ.

Parameters

ParameterTypeDescription
eventPitcherEventThe event to broadcast.

Returns

Promise<any>

Example

ts
usePitcherApi()
  .broadcast({
    type: "canvas_updated",
    body: { context: { myContextProperty: 'test' } },
  })
  .then(function (result) {
    useUi().toast({
      message: "Canvas Populated.",
      type: "info",
    })
  })

broadcastToWebviews()

broadcastToWebviews: (event) => Promise<any>

Broadcast an event to webviews only (iOS only).

Parameters

ParameterTypeDescription
eventPitcherEventThe event to broadcast.

Returns

Promise<any>

Example

ts
usePitcherApi()
  .broadcastToWebviews({
    type: "canvas_updated",
    body: { context: { myContextProperty: 'test' } },
  })
  .then(function (result) {
    useUi().toast({
      message: "Canvas Populated.",
      type: "info",
    })
  })

enterFullscreen()

enterFullscreen: () => Promise<any>

Make the entire CatalogIQ fullscreen.

Returns

Promise<any>

Example

ts
usePitcherApi().enterFullscreen()

exitFullscreen()

exitFullscreen: () => Promise<any>

Exit fullscreen mode.

Returns

Promise<any>

Example

ts
usePitcherApi().exitFullscreen()

getRequestTypes()

getRequestTypes: () => Promise<any>

Get the request types.

Returns

Promise<any>

isFullscreen()

isFullscreen: () => Promise<any>

Return is CatalogIQ in fullscreen.

Returns

Promise<any>

Example

ts
usePitcherApi().isFullscreen()

logout()

logout: () => Promise<any>

Log out the current user.

Returns

Promise<any>

Example

ts
usePitcherApi().logout()

off()

off: (type, callback) => void

Unsubscribe from a given event type by its key and the attached callback reference.

Parameters

ParameterTypeDescription
typestringThe event type to unsubscribe from.
callback(payload) => voidThe callback function reference to remove.

Returns

void

Example

ts
const callback = (event: object) => {
  // handle event
}
usePitcherApi().on('entered_fullscreen', callback)
// later
usePitcherApi().off('entered_fullscreen', callback)

on()

on: (type, callback) => void

Subscribe to a given event type by its key.

Parameters

ParameterTypeDescription
typestringThe event type to subscribe to.
callback(payload) => voidThe callback function to handle the event.

Returns

void

A Promise resolving to a cleanup function to unsubscribe from the event. *

Examples

ts
ts
const unsubscribeFromSectionListUpdate = usePitcherApi().on('entered_fullscreen', (event: object) => {
  // handle event
})
// later
unsubscribeFromSectionListUpdate()

quitInstance()

quitInstance: () => Promise<any>

Quit the current instance and go to the instance selection screen.

Returns

Promise<any>

Example

ts
usePitcherApi().quitInstance()

subscribe()

subscribe: () => Promise<any>

Subscribe to updates.

Returns

Promise<any>

unsubscribe()

unsubscribe: () => Promise<any>

Unsubscribe from updates.

Returns

Promise<any>

assignCanvasTheme()

Parameters

ParameterType
payload{ canvas_id: string; theme_id: string; }
payload.canvas_idstring
payload.theme_idstring

Returns

Promise<{ canvas_id: string; theme_id: string; }>

close()

Returns

Promise<any>

createCanvas()

Parameters

ParameterType
payloadOmit<CanvasCreateRequest, "instance_id">

Returns

Promise<CanvasRetrieve>

createEvent()

Parameters

ParameterType
payloadEventRequest

Returns

Promise<Event>

createFavorite()

Create a favorite

Parameters

ParameterType
payloadFavoriteCreateRequest

Returns

Promise<Favorite>

createFile()

Parameters

ParameterType
payloadOmit<AllFileCreateRequest, "instance_id">

Returns

Promise<FileRetrieve>

createFolder()

Creates a new folder.

Parameters

ParameterTypeDescription
payloadOmit<FolderCreateRequest, "instance_id">The folder creation request payload, excluding the instance_id.

Returns

Promise<FolderRetrieve>

A promise that resolves to the created folder.

crmQuery()

Parameters

ParameterType
payloadCRMQueryPayload

Returns

Promise<any>

crmSmartDeleteObjects()

Deletes CRM objects from local CRM data (iOS only). Uses Salesforce Mobile SDK SmartStore to delete records. Each object in the payload specifies a table name and an array of IDs to delete.

Parameters

ParameterTypeDescription
payloadCRMSmartDeleteObjectsPayloadThe delete payload containing an array of CRMDeleteObject items.

Returns

Promise<any>

  • Promise resolving with the result of the delete operation.

Throws

  • Throws an error if the payload is invalid.

Example

ts
// iOS only method to delete CRM objects.
api.crmSmartDeleteObjects({
  objects: [
    {
      table_name: 'Account',
      ids: ['001xx000003DGbQAAW', '001xx000003DGbRABW']
    },
    {
      table_name: 'Contact',
      ids: ['003xx000004TmiQAAS']
    }
  ]
})

crmSmartObjectMetadata()

Retrieves metadata for a CRM smart object (iOS only). Fetches object metadata from the Salesforce Mobile SDK cache.

Parameters

ParameterTypeDescription
payloadCRMSmartObjectMetadataPayloadThe payload containing the object name.

Returns

Promise<any>

  • Promise resolving with the object metadata.

Throws

  • Throws an error if the object name is not provided.

Example

ts
// iOS only method to retrieve CRM object metadata.
api.crmSmartObjectMetadata({ object: 'Account' })

crmSmartObjectValidationRules()

Retrieves validation rules for a CRM smart object (iOS only). This method fetches the validation rules configured for a specific CRM object type from the local SmartStore cache.

Parameters

ParameterTypeDescription
payloadCRMSmartObjectValidationRulesPayloadThe payload containing the object name.

Returns

Promise<any>

  • Promise resolving with the validation rules for the specified object.

Examples

ts
// iOS only method to get validation rules for an Account object.
api.crmSmartObjectValidationRules({ object: 'Account' })
ts
// Get validation rules for a Contact object.
api.crmSmartObjectValidationRules({ object: 'Contact' })

crmSmartQuery()

Executes a SmartStore query against local CRM data (iOS only). Uses Salesforce Mobile SDK SmartStore query syntax. Validates that the query uses SmartStore syntax before execution.

Parameters

ParameterTypeDescription
payloadCRMQueryPayloadThe query payload containing the SmartStore query string.

Returns

Promise<any[]>

  • Promise resolving with an array of query results from SmartStore.

Throws

  • Throws an error if the query is not a valid SmartStore query.

Example

ts
// iOS only method to execute a SmartStore query.
api.crmSmartQuery({ query: 'SELECT {Account:Id}, {Account:Name} FROM {Account} ORDER BY {Account:Name} LIMIT 10' })

crmSmartUpsertObjects()

Upserts CRM objects into local CRM data (iOS only). Uses Salesforce Mobile SDK SmartStore to insert or update records. Each object in the payload specifies a table name, the objects to upsert, and an optional external ID path.

Important: Always provide external_id_path when performing updates to ensure records are matched correctly. Without it, the operation may create duplicate records instead of updating existing ones.

Note: When creating new records, you must provide an explicit identifier field (e.g., Id) in each record object passed from the frontend. The backend does not auto-generate IDs.

Parameters

ParameterTypeDescription
payloadUpsertCRMObjectsPayloadThe upsert payload containing an array of UpsertCRMObject items.

Returns

Promise<any>

  • Promise resolving with the result of the upsert operation.

Throws

  • Throws an error if the payload is invalid.

Example

ts
// iOS only method to upsert CRM objects.

// Updating existing records - always include external_id_path
api.crmSmartUpsertObjects({
  objects: [
    {
      table_name: 'Account',
      objects: [{ Id: '001xx000003DGbQAAW', Name: 'Acme Corp Updated' }],
      external_id_path: 'Id' // Required for updates to match existing records
    }
  ]
})

// Creating new records - explicit ID required in each record
api.crmSmartUpsertObjects({
  objects: [
    {
      table_name: 'Account',
      objects: [
        { Id: '001xx000003NEW001', Name: 'New Company' }, // Explicit ID required
        { Id: '001xx000003NEW002', Name: 'Another Company' }
      ]
    }
  ]
})

deleteCanvas()

Parameters

ParameterType
payload{ id: string; }
payload.idstring

Returns

Promise<CanvasRetrieve>

deleteEvent()

Parameters

ParameterType
payloadPartial<Event>

Returns

Promise<void>

deleteFavorite()

Delete a favorite

Parameters

ParameterType
payload{ favorite_id: string; }
payload.favorite_idstring

Returns

Promise<void>

deleteFile()

Parameters

ParameterType
payload{ file_id: string; }
payload.file_idstring

Returns

Promise<string>

deleteFolder()

Deletes a folder.

Parameters

ParameterTypeDescription
payload{ folder_id: string; }An object containing the ID of the folder to delete.
payload.folder_idstringThe ID of the folder to delete.

Returns

Promise<void>

A promise that resolves when the folder is deleted.

deleteLocalFile()

Deletes a local file on iOS devices from Pitcher Folders.

Parameters

ParameterType
payload{ url: string; }
payload.urlstring

Returns

Promise<void>

Example

ts
// iOS only method to delete a local file.
api.deleteLocalFile({ url: 'file:///var/mobile/Containers/Data/Application/x/Documents/Pitcher%20Folders/ARPhotocapture/x.png' })

downloadFile()

Parameters

ParameterType
payload{ file_id: string; }
payload.file_idstring

Returns

Promise<null>

fetchDocumentInfo()

Parameters

ParameterType
payload{ fileId: string; }
payload.fileIdstring

Returns

Promise<{ [key: string]: unknown; pageCount: number; }>

Deprecated

  • not used anymore

getAppConfig()

Parameters

ParameterType
payload?{ app_name: string; }
payload.app_name?string

Returns

Promise<Record<string, any>>

getCanvas()

Parameters

ParameterType
payload{ fields: string; id: string; }
payload.fields?string
payload.idstring

Returns

Promise<CanvasRetrieve>

getCanvases()

Fetches a list of canvases to use in your app.

Parameters

ParameterType
payloadGetCanvasesParams & object

Returns

Promise<PaginatedData<CanvasRetrieve>>

Example

ts
// The `filters` object is a reserved payload key to transfer the metadata dict over the wire.
api.getCanvases({
  search: 'my search query',
  ordering: '-created_at',
  filters: {
    metadata__mydaterangefiltername__range: ['2023-12-10', '2023-12-22'],
    metadata__mymultiselectfiltername: ['optionAValue', 'optionCValue'],
  },
 fields: 'id,name,metadata',
})

getCanvasRecommendedFiles()

Parameters

ParameterType
payload{ canvas_id: string; match: ("metadata" | "tags")[]; }
payload.canvas_idstring
payload.match?("metadata" | "tags")[]

Returns

Promise<CanvasRecommendedFiles>

getCanvasTheme()

Parameters

ParameterType
payload{ canvas_id: string; }
payload.canvas_idstring

Returns

Promise<CanvasThemeRetrieve>

getCoreFolders()

Parameters

ParameterType
payload{ entity: CoreFolderEntityType; instance_id: string; parent_id: null | string; }
payload.entityCoreFolderEntityType
payload.instance_idstring
payload.parent_id?null | string

Returns

Promise<CoreFolderContentsRetrieve>

getEnv()

Fetches the necessary info for the app to know where it is embedded.

It contains information about:

  • user
  • instance
  • organization
  • security token to query Pitcher REST API
  • Salesforce connection information (if connected) including security token to query Salesforce REST API
  • Auth0 token information

Returns

Promise<PitcherEnv>

Example

ts
const env = usePitcherApi().getEnv().then((env) => {
  console.log(env.pitcher.user.name)
})

getEvents()

Parameters

ParameterType
payloadPartial<EventRequest>

Returns

Promise<PaginatedData<Event>>

getFavorites()

Get a list of favorites

Parameters

ParameterType
payload?GetFavoritesParams

Returns

Promise<PaginatedFavoriteList>

getFile()

Parameters

ParameterType
payload{ file_id: string; id: string; }
payload.file_id?string
payload.id?string

Returns

Promise<FileRetrieve>

getFileRevisionData()

Parameters

ParameterType
payload{ file_id: string; revision_id: string; }
payload.file_idstring
payload.revision_idstring

Returns

Promise<FileRetrieve>

getFileRevisions()

Parameters

ParameterType
payload{ file_id: string; id: string; }
payload.file_id?string
payload.id?string

Returns

Promise<FileRevision[]>

getFiles()

Parameters

ParameterType
payloadPartial<Omit<File, "type">> & object & object

Returns

Promise<PaginatedFileList>

getFolder()

Retrieves a folder by its ID.

Parameters

ParameterTypeDescription
payload{ id: string; }An object containing the folder ID.
payload.idstringThe ID of the folder to retrieve. Defaults to 'root'.

Returns

Promise<FolderRetrieve>

A promise that resolves to the retrieved folder.

getFolders()

Retrieves a list of folders.

Parameters

ParameterTypeDescription
payloadFolderListRequestThe payload containing the search, ordering, filters, fields, name, page, and page_size.

Returns

Promise<PaginatedFolderList>

A promise that resolves to the list of folders.

getInstanceMetadataTemplates()

Parameters

ParameterType
payload?GetInstanceMetadataTemplatesPayload

Returns

Promise<PaginatedMetadataTemplateList>

getLanguages()

Fetches available languages for the logged-in user

Returns

Promise<Language[]>

getRecentFiles()

Parameters

ParameterType
payload?GetRecentFilesPayload

Returns

Promise<File[]>

getThemes()

Parameters

ParameterType
payloadPartial<CanvasThemeRetrieve>

Returns

Promise<CanvasThemeRetrieve[]>

getUsers()

Parameters

ParameterType
payload?GetUsersParams

Returns

Promise<PaginatedData<User>>

isOffline()

Returns

Promise<boolean>

moveFolderItems()

Moves items (files or folders) to a target folder.

Parameters

ParameterTypeDescription
payload{ items: object[]; target_folder_id: string; }The payload containing the target folder ID and items to move.
payload.itemsobject[]An array of items to move, each with an ID and type.
payload.target_folder_idstringThe ID of the target folder.

Returns

Promise<FolderRetrieve>

A promise that resolves to the updated target folder.

notify()

Parameters

ParameterType
payloadNotificationPayload

Returns

Promise<void>

open()

Open a file in the CatalogIQ instance.

Parameters

ParameterType
payloadOpenRequestPayload

Returns

Promise<string>

openExternalUrl()

Open external URL in a new tab. Works on both web and mobile.

Parameters

ParameterType
payloadOpenExternalUrlRequestPayload

Returns

Promise<void>

openWebViewAlwaysOnTop()

Parameters

ParameterType
payloadOpenWebViewAlwaysOnTop

Returns

Promise<void>

patchCoreFolder()

Parameters

ParameterType
idstring
payloadPartial<CoreFolderRetrieve>

Returns

Promise<CoreFolderContentsRetrieve>

query()

Parameters

ParameterType
payloadQueryPayload

Returns

Promise<any>

refreshAccessToken()

Returns

any

refreshServiceToken()

Ask for a refreshed Salesforce token. In case the token hasn't expired yet, this method will return the same token as the current one found in the (getEnv)[#getenv] result.

Parameters

ParameterType
payload?RefreshServiceTokenRequest

Returns

Promise<RefreshServiceTokenResponse>

Promise resolving to an object containing the token

renderPageAsImage()

Renders a page from a file together with annotations.

Parameters

ParameterTypeDescription
payload{ documentId: string; fileId: string; pageIndex: number; params: { width: number; } | { height: number; }; }-
payload.documentId?stringThe ID of the document to render (optional). If not provided the fileId will be used.
payload.fileIdstringThe ID of the file to render. Used when the documentId is not available.
payload.pageIndexnumberThe index of the page to render.
payload.params{ width: number; } | { height: number; }The parameters to use for rendering the page.

Returns

Promise<ArrayBuffer>

A promise that resolves with the image as an ArrayBuffer.

Example

ts
api.renderPageAsImage({
  fileId: '123456',
  documentId: '654321',
  pageIndex: 0,
  params: { width: 1920 },
})

Parameters

ParameterType
payload{ includeExpired: boolean; query: string; }
payload.includeExpired?boolean
payload.querystring

Returns

Promise<any>

selectDeviceFile()

Dispatches iOS native file selector and returns the selected file.

Returns

Promise<DeviceFile>

Example

ts
// iOS only method to select a file from the device.
api.selectDeviceFile()

share()

Dispatch iOS sharing dialog.

Parameters

ParameterType
payloadSharePayload

Returns

Promise<ShareResponse>

Example

ts
api.share({text: "example text", subject: "example subject"})

shareCanvas()

Parameters

ParameterType
payload{ id: string; }
payload.idstring

Returns

Promise<SharedLink>

showPeerSession()

Show peer session dialog with button coordinates, for local peer sharing feature.

Parameters

ParameterType
payloadShowPeerSessionRequestPayload

Returns

Promise<void>

Example

ts
api.showPeerSession({x: 100, y: 200})

showSyncbox()

Parameters

ParameterType
payloadShowSyncboxRequestPayload

Returns

Promise<void>

submitUserFeedback()

Submit user feedback

Parameters

ParameterType
payloadSubmitUserFeedbackPayload

Returns

Promise<any>

toast()

Parameters

ParameterType
payload{ message: string; type: string; }
payload.messagestring
payload.typestring

Returns

Promise<void>

track()

Parameters

ParameterType
payload{ event_name: string; payload: any; }
payload.event_namestring
payload.payloadany

Returns

Promise<any>

triggerNonFilesSync()

Dispatches iOS only sync method for non-files.

Returns

Promise<void>

Example

ts
// iOS only method to sync non-files from the server.
api.triggerNonFilesSync()

unassignCanvasTheme()

Parameters

ParameterType
payload{ canvas_id: string; }
payload.canvas_idstring

Returns

Promise<void>

updateCanvas()

Updates a canvas by ID

Parameters

ParameterType
payloadPatchedCanvasUpdateRequest & object

Returns

Promise<CanvasRetrieve>

Example

ts
// The fields param is appended to the URL as a query param.
onMounted(() => {
  PitcherAPI.updateCanvas({
    id: '01HH4RCBH631K4JDHWAQB0RPR6',
    fields: 'id,name',
    name: 'To 3!',
  }).then((res) => {
    console.log(res)  // logs: { id: '01HH4RCBH631K4JDHWAQB0RPR6', name: 'To 3!' }
  })
})

updateCanvasIndicators()

Updates canvas indicators by canvas ID. It merges the passed object into existing canvas indicators adding new keys if they were empty and overriding pre-existing keys.

Indicators can also be updated using updateCanvas API but in this case passed object fully replaces existing indicators.

Parameters

ParameterType
payload{ id: string; indicators: Record<string, CanvasIndicator>; instance_id: string; }
payload.idstring
payload.indicatorsRecord<string, CanvasIndicator>
payload.instance_id?string

Returns

Promise<CanvasRetrieve>

Example

ts
// The fields param is appended to the URL as a query param.
onMounted(() => {
  PitcherAPI.updateCanvasIndicators({
    id: '01J9XT0WVXRTETF4CQZP42CPZP',
    indicators: {
      existing: { type: 'info', label: 'new label' }, // will be overriden
      new: { type: 'info', label: 'INFO' }, // will be added
      removeExisting: null // will be set to null and ignored, it is the same as removal
   }
   }).then((res) => {
    console.log(res)  // entire canvas object, including indicators field
  })
})

updateEvent()

Parameters

ParameterType
payloadPatchedEventRequest

Returns

Promise<Event>

updateFile()

Parameters

ParameterType
payloadFileUpdateRequest & object

Returns

Promise<FileRetrieve>

updateFolder()

Updates an existing folder.

Parameters

ParameterTypeDescription
payloadUpdateFolderPayloadThe folder update payload, including the folder ID and update data.

Returns

Promise<FolderRetrieve>

A promise that resolves to the updated folder.

updateMyUser()

Parameters

ParameterType
payloadUpdateEnvParams

Returns

Promise<User>