# Files

Use the file entity to store files and related metadata.
Files can be sorted by size, MIME-type, user-defined tags, and description.

The following methods are available to upload files:
multipart/form-data encoded form, RAW POST &mdash;
by sending the file contents as the POST body, and fetching from URL &mdash;
by providing the file URL using the 'url' parameter.

Use the attachments entity to link a file to one or multiple objects, such as:
customer, dispute, transaction, order, plan, product, invoice, or timeline comment.
Attachments enable you to quickly find and use files related to specific entities.

## Retrieve attachments

 - [GET /attachments](https://www.rebilly.com/docs/dev-docs/api/files/getattachmentcollection.md): Retrieves a list of attachments. You may sort attachments by: id,
name, relatedId, relatedType, fileId, createdTime,
and updatedTime.

## Create an attachment

 - [POST /attachments](https://www.rebilly.com/docs/dev-docs/api/files/postattachment.md): Attaches a file to one or multiple objects, such as: customer,
dispute, transaction, order, plan, product, invoice, or timeline
comment. Attachments enable you to quickly find and use files
related to specific entities.

## Retrieve an attachment

 - [GET /attachments/{id}](https://www.rebilly.com/docs/dev-docs/api/files/getattachment.md): Retrieves an attachment with a specified ID.

## Update an attachment

 - [PUT /attachments/{id}](https://www.rebilly.com/docs/dev-docs/api/files/putattachment.md): Updates an attachment with a specified ID.

## Delete an attachment

 - [DELETE /attachments/{id}](https://www.rebilly.com/docs/dev-docs/api/files/deleteattachment.md): Deletes an attachment with a specified ID.

## Retrieve files

 - [GET /files](https://www.rebilly.com/docs/dev-docs/api/files/getfilecollection.md): Retrieves a list of files.

## Create a file

 - [POST /files](https://www.rebilly.com/docs/dev-docs/api/files/postfile.md): Creates a file.

Additionally, a file can be sent by:

 - Multipart/form-data POST request: In this request,
 the file is uploaded and all property names are the same as the JSON names.
 - File body request: In this request,
 the file body is sent as the request body, with the appropriate Content-Type.
 No additional properties can be set with the request data.

Permitted file types: .jpg, .png, .gif, and .pdf.

When using a publishable API key, only private files can be created.
The files can be modified at a later point or time,
or can be accessed using a secret API key.

## Retrieve a file record

 - [GET /files/{id}](https://www.rebilly.com/docs/dev-docs/api/files/getfile.md): Retrieves a file with a specified ID.

## Update a file

 - [PUT /files/{id}](https://www.rebilly.com/docs/dev-docs/api/files/putfile.md): Updates a file with a specified ID.

> Note: Files can only be uploaded by POST request.
For more information, see the Create a file operation.

## Delete a file

 - [DELETE /files/{id}](https://www.rebilly.com/docs/dev-docs/api/files/deletefile.md): Deletes a file with a specified ID.

## Download a file

 - [GET /files/{id}/download](https://www.rebilly.com/docs/dev-docs/api/files/getfiledownload.md): Downloads a file with a specified ID.

