Box Component

Available as of Camel 2.14

The Box component provides access to all of the APIs accessible using box-java-sdk-v2. It allows producing messages to upload and download files, create, edit, and manage folders, etc. It also supports APIs that allow polling for updates to user accounts and even changes to enterprise accounts, etc. requires the use of OAuth2.0 for all client application authentication. In order to use camel-box with your account, you'll need to create a new application within at The Box application's client id and secret will allow access to Box APIs which require a current user. A user access token is generated and managed by the API for an end user. Alternatively the Camel application can register an implementation of to provide an OAuth token.

Maven users will need to add the following dependency to their pom.xml for this component:

URI format

Endpoint prefix can be one of:

  • collaborations
  • comments
  • events
  • files
  • folders
  • groups
  • poll-events
  • search
  • shared-comments
  • shared-files
  • shared-folders
  • shared-items
  • users


The Box Component can be configured with the options below. These options can be provided using the component's bean property configuration of type These options can also be specified in the endpoint URI. 

OptionTypeDescription Secure Storage callback, can be used to provide and or save OAuth tokens. The callback may return null on first call to allow the component to login and authorize application and obtain an OAuth token, which can then be saved in the secure storage. For the component to be able to create a token automatically a user password must be provided. Box SDK configuration, not required normally
clientIdStringBox application client ID
clientSecretStringBox application client secret Box connection manager builder, used to override default settings like max connections for underlying HttpClient.
httpParamsjava.util.MapCustom HTTP params for settings like proxy host
loginTimeoutintamount of time the component will wait for a response from, default is 30 seconds listener for token updates, if the Camel application needs to use the access token outside the route
revokeOnShutdownbooleanFlag to revoke OAuth refresh token on route shutdown, default false. Will require a fresh refresh token on restart using either a custom IAuthSecureStorage or automatic component login by providing a user password
sharedLinkStringBox shared link for shared-* endpoints, can be a link for a shared comment, file or folder
sharedPasswordStringPassword associated with the shared link, MUST be provided with sharedLink
userNameStringBox user name, MUST be provided
userPasswordStringBox user password, MUST be provided if authSecureStorage is not set, or returns null on first call

Producer Endpoints:

Producer endpoints can use endpoint prefixes followed by endpoint names and associated options described next. A shorthand alias can be used for some endpoints. The endpoint URI MUST contain a prefix.

Endpoint options that are not mandatory are denoted by []. When there are no mandatory options for an endpoint, one of the set of [] options MUST be provided. Producer endpoints can also use a special option inBody that in turn should contain the name of the endpoint option whose value will be contained in the Camel Exchange In message.

Any of the endpoint options can be provided in either the endpoint URI, or dynamically in a message header. The message header name must be of the format CamelBox.<option>. Note that the inBody option overrides message header, i.e. the endpoint option inBody=option would override a CamelBox.option header.

If a value is not provided for the option defaultRequest either in the endpoint URI or in a message header, it will be assumed to be null. Note that the null value will only be used if other options do not satisfy matching endpoints.

In case of Box API errors the endpoint will throw a RuntimeCamelException with a derived exception cause.

Endpoint Prefix collaborations

For more information on Box collaborations see The following endpoints can be invoked with the prefix collaborations as follows:

EndpointShorthand AliasOptionsResult Body Type
deleteCollaborationdeletecollabId, defaultRequest 
URI Options for collaborations

Endpoint Prefix events

For more information on Box events see Although this endpoint can be used by producers, Box events are better used as a consumer endpoint using the poll-events endpoint prefix. The following endpoints can be invoked with the prefix events as follows:

EndpointShorthand AliasOptionsResult Body Type
URI Options for events

Endpoint Prefix groups

For more information on Box groups see The following endpoints can be invoked with the prefix groups as follows:

EndpointShorthand AliasOptionsResult Body Type
createGroup [groupRequest], [name]
createMembership [groupId, role, userId], [groupMembershipRequest]
deleteGroupdeletedefaultRequest, groupId 
deleteMembershipdeletedefaultRequest, membershipId 
updateMembershipupdate[groupMembershipRequest], [role],
URI Options for groups

Endpoint Prefix search

For more information on Box search API see The following endpoints can be invoked with the prefix search as follows:

EndpointShorthand AliasOptionsResult Body Type
search defaultRequest,
URI Options for search

Endpoint Prefix comments and shared-comments

For more information on Box comments see The following endpoints can be invoked with the prefix comments or shared-comments as follows. The shared-comments prefix requires sharedLink and sharedPassword properties. 

EndpointShorthand AliasOptionsResult Body Type
addComment [commentRequest], [commentedItemId, commentedItemType, message]
deleteCommentdeletecommentId, defaultRequest 
URI Options for comments and shared-comments

Endpoint Prefix files and shared-files

For more information on Box files see The following endpoints can be invoked with the prefix files or shared-files as follows. The shared-files prefix requires sharedLink and sharedPassword properties. 

EndpointShorthand AliasOptionsResult Body Type
copyFile fileId,
deleteFile defaultRequest, fileId 
downloadFiledownload[destination, listener], [listener, outputStreams], defaultRequest,
downloadThumbnaildownloadextension, fileId,
getFileVersionsfileVersionsdefaultRequest, fileIdjava.util.List
getPreviewpreviewextension, fileId,
getThumbnailthumbnailextension, fileId,
URI Options for files and shared-files

Endpoint Prefix folders and shared-folders

For more information on Box folders see The following endpoints can be invoked with the prefix folders or shared-folders as follows. The prefix shared-folders requires sharedLink and sharedPassword properties. 

EndpointShorthand AliasOptionsResult Body Type
copyFolder folderId,
deleteFolderdeletefolderDeleteRequest, folderId 
getFolderCollaborationsfolderCollaborationsdefaultRequest, folderIdjava.util.List
URI Options for folders or shared-folders



Endpoint Prefix shared-items

For more information on Box shared items see The following endpoints can be invoked with the prefix shared-items as follows:

EndpointShorthand AliasOptionsResult Body Type
URI Options for shared-items

Endpoint Prefix users

For information on Box users see The following endpoints can be invoked with the prefix users as follows:

EndpointShorthand AliasOptionsResult Body Type
addEmailAlias emailAliasRequest,
deleteEmailAlias defaultRequest, emailId, userId 
deleteEnterpriseUser userDeleteRequest, userId 
getAllEnterpriseUserallEnterpriseUserdefaultRequest, filterTermjava.util.List
getEmailAliasesemailAliasesdefaultRequest, userIdjava.util.List
moveFolderToAnotherUser folderId, simpleUserRequest,
URI Options for users

Consumer Endpoints:

For more information on Box events see and for long polling see Consumer endpoints can only use the endpoint prefix poll-events as shown in the example next. By default the consumer will split the from every long poll and create an exchange for every To make the consumer return the entire collection in a single exchange, use the URI option consumer.splitResult=false.

EndpointShorthand AliasOptionsResult Body Type
poll limit, streamPosition, streamType by default, or when consumer.splitResult=false
URI Options for poll-events

Message header

Any of the options can be provided in a message header for producer endpoints with CamelBox. prefix.

Message body

All result message bodies utilize objects provided by the Box Java SDK. Producer endpoints can specify the option name for incoming message body in the inBody endpoint parameter.

Type Converter

The Box component also provides a Camel type converter to convert GenericFile objects from File component to a to upload files to The target folderId for the upload can be specified in the exchange property CamelBox.folderId. If the exchange property is not specified the value defaults to "0" for the root folder ID. 

Use cases

The following route uploads new files to the user's root folder:

The following route polls user's account for updates:

The following route uses a producer with dynamic header options. The fileId property has the Box file id , so its assigned to the CamelBox.fileId header as follows:

© 2004-2015 The Apache Software Foundation.
Apache Camel, Camel, Apache, the Apache feather logo, and the Apache Camel project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
Graphic Design By Hiram