# Bundles
Bundles are the API/SDK term for the feature called Share Links in the web interface.
The API provides the full set of actions related to Share Links, including sending them via E-Mail.
Please note that we very closely monitor the E-Mailing feature and any abuse will result in disabling of your site.
## The Bundle object
> Example Bundle Object
```json
{
"id": 1,
"code": "abc123",
"created_at": "2000-01-01T01:00:00Z",
"description": "The public description of the bundle.",
"expires_at": "2000-01-01T01:00:00Z",
"paths": [
],
"note": "The internal note on the bundle.",
"password_protected": true,
"url": "https://subdomain.files.com/f/12345678",
"user_id": 1,
"username": "user"
}
```
```xml
1
abc123
2000-01-01T01:00:00Z
The public description of the bundle.
2000-01-01T01:00:00Z
The internal note on the bundle.
true
https://subdomain.files.com/f/12345678
1
user
```
Attribute | Description
--------- | -----------
id *int64* | Bundle ID
code *string* | Bundle code. This code forms the end part of the Public URL.
created_at *date-time* | Bundle created at date/time
description *string* | Public description
expires_at *date-time* | Bundle expiration date/time
paths *array* | A list of paths in this bundle
note *string* | Bundle internal note
password_protected *boolean* | Is this bundle password protected?
url *string* | Public URL of Share Link
user_id *int64* | Bundle creator user ID
username *string* | Bundle creator username
password *string* | Password for this bundle.
## List Bundles
> Example Request
```shell--json
curl "https://app.files.com/api/rest/v1/bundles.json?user_id=1&page=1&per_page=1" \
-H 'X-FilesAPI-Key: YOUR_API_KEY'
```
```shell--xml
curl "https://app.files.com/api/rest/v1/bundles.xml?user_id=1&page=1&per_page=1" \
-H 'X-FilesAPI-Key: YOUR_API_KEY'
```
```ruby
Files.api_key = 'YOUR_API_KEY'
Files::Bundle.list(
user_id: 1,
page: 1,
per_page: 1
)
```
```php
\Files\Files::setApiKey('YOUR_API_KEY');
\Files\Bundle::list(array(
'user_id' => 1,
'page' => 1,
'per_page' => 1
));
```
> Example Response
```json
[
{
"id": 1,
"code": "abc123",
"created_at": "2000-01-01T01:00:00Z",
"description": "The public description of the bundle.",
"expires_at": "2000-01-01T01:00:00Z",
"paths": [
],
"note": "The internal note on the bundle.",
"password_protected": true,
"url": "https://subdomain.files.com/f/12345678",
"user_id": 1,
"username": "user"
}
]
```
```xml
1
abc123
2000-01-01T01:00:00Z
The public description of the bundle.
2000-01-01T01:00:00Z
The internal note on the bundle.
true
https://subdomain.files.com/f/12345678
1
user
```
### HTTPS Request
`GET /bundles`
### Authentication Required
Available to all authenticated keys or sessions.
### Request Parameters
Parameter | Description
--------- | --------- | -----------
user_id *int64* | User ID. Provide a value of `0` to operate the current session's user.
page *int64* | Current page number.
per_page *int64* | Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
action *string* | Deprecated: If set to `count` returns a count of matching records rather than the records themselves.
## Show Bundle
> Example Request
```shell--json
curl https://app.files.com/api/rest/v1/bundles/{id}.json \
-H 'X-FilesAPI-Key: YOUR_API_KEY'
```
```shell--xml
curl https://app.files.com/api/rest/v1/bundles/{id}.xml \
-H 'X-FilesAPI-Key: YOUR_API_KEY'
```
```ruby
Files.api_key = 'YOUR_API_KEY'
Files::Bundle.find(id)
```
```php
\Files\Files::setApiKey('YOUR_API_KEY');
\Files\Bundle::find($id);
```
> Example Response
```json
{
"id": 1,
"code": "abc123",
"created_at": "2000-01-01T01:00:00Z",
"description": "The public description of the bundle.",
"expires_at": "2000-01-01T01:00:00Z",
"paths": [
],
"note": "The internal note on the bundle.",
"password_protected": true,
"url": "https://subdomain.files.com/f/12345678",
"user_id": 1,
"username": "user"
}
```
```xml
1
abc123
2000-01-01T01:00:00Z
The public description of the bundle.
2000-01-01T01:00:00Z
The internal note on the bundle.
true
https://subdomain.files.com/f/12345678
1
user
```
### HTTPS Request
`GET /bundles/{id}`
### Authentication Required
Available to all authenticated keys or sessions.
### Request Parameters
Parameter | Description
--------- | --------- | -----------
id *int64* **Required** | Bundle ID.
## Create Bundle
> Example Request
```shell--json
curl https://app.files.com/api/rest/v1/bundles.json \
-X POST \
-H 'Content-Type: application/json' \
-d '{"user_id":1,"paths":["file.txt"],"password":"Password","expires_at":"2000-01-01T01:00:00Z","description":"Public description","note":"Internal Note","code":"abc123"}' \
-H 'X-FilesAPI-Key: YOUR_API_KEY'
```
```shell--xml
curl https://app.files.com/api/rest/v1/bundles.xml \
-X POST \
-H 'Content-Type: application/xml' \
-d '
1
file.txt
Password
2000-01-01T01:00:00Z
Public description
Internal Note
abc123
'
-H 'X-FilesAPI-Key: YOUR_API_KEY'
```
```ruby
Files.api_key = 'YOUR_API_KEY'
Files::Bundle.create(
user_id: 1,
paths: ["file.txt"],
password: "Password",
expires_at: "2000-01-01T01:00:00Z",
description: "Public description",
note: "Internal Note",
code: "abc123"
)
```
```php
\Files\Files::setApiKey('YOUR_API_KEY');
\Files\Bundle::create(array(
'user_id' => 1,
'paths' => ["file.txt"],
'password' => "Password",
'expires_at' => "2000-01-01T01:00:00Z",
'description' => "Public description",
'note' => "Internal Note",
'code' => "abc123"
));
```
> Example Response
```json
{
"id": 1,
"code": "abc123",
"created_at": "2000-01-01T01:00:00Z",
"description": "The public description of the bundle.",
"expires_at": "2000-01-01T01:00:00Z",
"paths": [
],
"note": "The internal note on the bundle.",
"password_protected": true,
"url": "https://subdomain.files.com/f/12345678",
"user_id": 1,
"username": "user"
}
```
```xml
1
abc123
2000-01-01T01:00:00Z
The public description of the bundle.
2000-01-01T01:00:00Z
The internal note on the bundle.
true
https://subdomain.files.com/f/12345678
1
user
```
### HTTPS Request
`POST /bundles`
### Authentication Required
Available to all authenticated keys or sessions.
### Request Parameters
Parameter | Description
--------- | --------- | -----------
user_id *int64* | User ID. Provide a value of `0` to operate the current session's user.
paths *array(string)* **Required** | A list of paths to include in this bundle.
password *string* | Password for this bundle.
expires_at *string* | Bundle expiration date/time.
description *string* | Bundle public description
note *string* | Bundle internal note
code *string* | Bundle name
## Send email(s) with a link to bundle
> Example Request
```shell--json
curl https://app.files.com/api/rest/v1/bundles/{id}/share.json \
-X POST \
-H 'Content-Type: application/json' \
-d '{"to":["johndoe@gmail.com"],"note":"Just a note."}' \
-H 'X-FilesAPI-Key: YOUR_API_KEY'
```
```shell--xml
curl https://app.files.com/api/rest/v1/bundles/{id}/share.xml \
-X POST \
-H 'Content-Type: application/xml' \
-d '
johndoe@gmail.com
Just a note.
'
-H 'X-FilesAPI-Key: YOUR_API_KEY'
```
```ruby
Files.api_key = 'YOUR_API_KEY'
bundle = Files::Bundle.find(id)
bundle.share(
to: ["johndoe@gmail.com"],
note: "Just a note."
)
```
```php
\Files\Files::setApiKey('YOUR_API_KEY');
$bundle = \Files\Bundle->find(1);
$bundle->share(array(
'to' => ["johndoe@gmail.com"],
'note' => "Just a note."
));
```
> Example Response
```json
No response.
```
```xml
No response.
```
### HTTPS Request
`POST /bundles/{id}/share`
### Authentication Required
Available to all authenticated keys or sessions.
### Request Parameters
Parameter | Description
--------- | --------- | -----------
id *int64* **Required** | Bundle ID.
to *array(string)* **Required** | A list of email addresses to share this bundle with.
note *string* | Note to include in email.
## Delete Bundle
> Example Request
```shell--json
curl https://app.files.com/api/rest/v1/bundles/{id}.json \
-X DELETE \
-H 'X-FilesAPI-Key: YOUR_API_KEY'
```
```shell--xml
curl https://app.files.com/api/rest/v1/bundles/{id}.xml \
-X DELETE \
-H 'X-FilesAPI-Key: YOUR_API_KEY'
```
```ruby
Files.api_key = 'YOUR_API_KEY'
bundle = Files::Bundle.find(id)
bundle.delete
```
```php
\Files\Files::setApiKey('YOUR_API_KEY');
$bundle = \Files\Bundle->find(1);
$bundle->delete();
```
> Example Response
```json
No response.
```
```xml
No response.
```
### HTTPS Request
`DELETE /bundles/{id}`
### Authentication Required
Available to all authenticated keys or sessions.
### Request Parameters
Parameter | Description
--------- | --------- | -----------
id *int64* **Required** | Bundle ID.