Functions for interacting with company and employee file resources in the BambooHR API.
Covers file categories, uploads, downloads, metadata updates, and deletion, for both company-wide files and employee-scoped files.
Summary
Functions
Creates one or more company file categories.
Creates one or more employee file categories (not company file categories).
Permanently deletes a company file.
Permanently deletes an employee file.
Downloads a company file by its ID.
Downloads an employee file by its ID.
Retrieves all company file categories and the files within each category that the requesting user is permitted to see.
Lists the file categories and files visible to the caller for the specified employee.
Updates metadata for an existing company file.
Updates metadata for an existing employee file.
Uploads a file to a company file category.
Uploads a file to an employee's file section.
Functions
@spec create_company_file_category(BambooHR.Client.t(), [String.t()]) :: BambooHR.Client.response()
Creates one or more company file categories.
On success, returns nil (no response body).
Parameters
client- Client configuration created withBambooHR.Client.new/1category_names- List of category name strings; each must be non-empty and unique among existing company file categories
Examples
iex> BambooHR.Files.create_company_file_category(client, ["Contracts"])
{:ok, nil}
@spec create_employee_file_category(BambooHR.Client.t(), [String.t()]) :: BambooHR.Client.response()
Creates one or more employee file categories (not company file categories).
On success, returns nil (no response body).
Parameters
client- Client configuration created withBambooHR.Client.new/1category_names- List of category name strings; each must be non-empty and unique among existing employee file categories
Examples
iex> BambooHR.Files.create_employee_file_category(client, ["Certifications"])
{:ok, nil}
@spec delete_company_file(BambooHR.Client.t(), integer()) :: BambooHR.Client.response()
Permanently deletes a company file.
On success, returns nil (no response body).
Parameters
client- Client configuration created withBambooHR.Client.new/1file_id- The ID of the company file to delete
Examples
iex> BambooHR.Files.delete_company_file(client, 123)
{:ok, nil}
@spec delete_employee_file(BambooHR.Client.t(), integer(), integer()) :: BambooHR.Client.response()
Permanently deletes an employee file.
Pass 0 as employee_id to use the employee associated with the API
key. Idempotent — returns success even if the file was already deleted.
Parameters
client- Client configuration created withBambooHR.Client.new/1employee_id- The ID of the employee whose file is being deletedfile_id- The ID of the employee file to delete
Examples
iex> BambooHR.Files.delete_employee_file(client, 123, 456)
{:ok, nil}
@spec get_company_file(BambooHR.Client.t(), integer()) :: BambooHR.Client.response()
Downloads a company file by its ID.
Returns {:ok, %{body: binary_content, headers: headers}}. headers
includes "content-type" and "content-disposition" (which carries the
original filename) as BambooHR set them.
Parameters
client- Client configuration created withBambooHR.Client.new/1file_id- The ID of the company file to download
Examples
iex> BambooHR.Files.get_company_file(client, 123)
{:ok, %{body: <<37, 80, 68, 70>>, headers: %{"content-type" => ["application/pdf"]}}}
@spec get_employee_file(BambooHR.Client.t(), integer(), integer()) :: BambooHR.Client.response()
Downloads an employee file by its ID.
Pass 0 as employee_id to use the employee associated with the API
key. Returns {:ok, %{body: binary_content, headers: headers}}.
headers includes "content-type" and "content-disposition" (which
carries the original filename) as BambooHR set them.
Parameters
client- Client configuration created withBambooHR.Client.new/1employee_id- The ID of the employee whose file is being retrievedfile_id- The ID of the employee file to download
Examples
iex> BambooHR.Files.get_employee_file(client, 123, 456)
{:ok, %{body: <<37, 80, 68, 70>>, headers: %{"content-type" => ["application/pdf"]}}}
@spec list_company_files(BambooHR.Client.t()) :: BambooHR.Client.response()
Retrieves all company file categories and the files within each category that the requesting user is permitted to see.
Parameters
client- Client configuration created withBambooHR.Client.new/1
Examples
iex> BambooHR.Files.list_company_files(client)
{:ok, %{"categories" => [%{"id" => 1, "name" => "Policies", "files" => []}]}}
@spec list_employee_files(BambooHR.Client.t(), integer()) :: BambooHR.Client.response()
Lists the file categories and files visible to the caller for the specified employee.
This is a metadata listing (names, sizes, permissions); to download a
file's content use get_employee_file/3.
Parameters
client- Client configuration created withBambooHR.Client.new/1employee_id- The ID of the employee whose files are being listed
Examples
iex> BambooHR.Files.list_employee_files(client, 123)
{:ok, %{"employee" => %{"id" => 123}, "categories" => []}}
@spec update_company_file(BambooHR.Client.t(), integer(), map()) :: BambooHR.Client.response()
Updates metadata for an existing company file.
Supports renaming the file, moving it to a different category, and
toggling employee visibility. Only fields included in update_data are
updated.
Parameters
client- Client configuration created withBambooHR.Client.new/1file_id- The ID of the company file to updateupdate_data- Map with any of"name","categoryId","shareWithEmployee"
Examples
iex> BambooHR.Files.update_company_file(client, 123, %{"name" => "handbook-v2.pdf"})
{:ok, nil}
@spec update_employee_file(BambooHR.Client.t(), integer(), integer(), map()) :: BambooHR.Client.response()
Updates metadata for an existing employee file.
Supports renaming the file, moving it to a different category, and
toggling employee visibility. Only fields included in update_data are
updated.
Parameters
client- Client configuration created withBambooHR.Client.new/1employee_id- The ID of the employee whose file is being updatedfile_id- The ID of the employee file to updateupdate_data- Map with any of"name","categoryId","shareWithEmployee"
Examples
iex> BambooHR.Files.update_employee_file(client, 123, 456, %{"name" => "resume-2024.pdf"})
{:ok, nil}
@spec upload_company_file( BambooHR.Client.t(), String.t(), integer(), binary(), keyword() ) :: BambooHR.Client.response()
Uploads a file to a company file category.
On success, returns {:ok, %{"location" => url}}, where url points to
the new file resource; {:ok, %{}} if no Location header is present.
Parameters
client- Client configuration created withBambooHR.Client.new/1file_name- Display name for the uploaded filecategory_id- ID of the file category (section) to upload intofile_content- Binary file contentopts- Optional keyword list::share- whether to share the file with all employees (defaults tofalse)
Examples
iex> BambooHR.Files.upload_company_file(client, "handbook.pdf", 3, pdf_binary)
{:ok, %{"location" => "https://acme.bamboohr.com/files/123"}}
@spec upload_employee_file( BambooHR.Client.t(), integer(), String.t(), integer(), binary(), keyword() ) :: BambooHR.Client.response()
Uploads a file to an employee's file section.
Pass 0 as employee_id to use the employee associated with the API
key. On success, returns {:ok, %{"location" => url}}, where url
points to the new file resource; {:ok, %{}} if no Location header is
present.
Parameters
client- Client configuration created withBambooHR.Client.new/1employee_id- The ID of the employee to upload the file forfile_name- Display name for the uploaded filecategory_id- ID of the employee file section to upload intofile_content- Binary file contentopts- Optional keyword list::share- whether to share the file with the employee (defaults tofalse)
Examples
iex> BambooHR.Files.upload_employee_file(client, 123, "resume.pdf", 5, pdf_binary)
{:ok, %{"location" => "https://acme.bamboohr.com/employees/files/456"}}