Sharing
The Sharing API allows you to create public links for files or folders, list your existing active shares, and cancel (delete) shares.
Create Share
Endpoint: POST /share/pset
This generates a public link (e.g., terabox.com/s/1abc...) for a list of file IDs.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
jsToken |
string | Yes | Session token. |
Body Data:
* fid_list: JSON array of File IDs (fs_id) to share.
* schannel: 0.
* channel_list: [] or [0].
* period: 0 for permanent, 1 for 1 day, 7 for 7 days, 30 for 30 days.
* public: 1 (Public link) or 0 (Private link with password - requires extra params).
Code Examples
=== "cURL"
```bash
curl -X POST "https://1024terabox.com/share/pset?jsToken=TOKEN" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "fid_list=[12345]&schannel=0&channel_list=[]&period=0&public=1"
```
=== "Python"
```python
import json
# List of file IDs (fs_id) to share
fid_list = [12345, 67890]
data = {
'schannel': '0',
'channel_list': '[]',
'period': '0', # 0 = Permanent
'path_list': '["/file1"]', # Optional if fid_list provided
'fid_list': json.dumps(fid_list),
'public': '1'
}
resp = session.post('https://1024terabox.com/share/pset', params={'jsToken': js_token}, data=data)
result = resp.json()
if result['errno'] == 0:
print(f"Share Link: {result['shorturl']}") # e.g. "1aBcDeF"
```
=== "Node.js"
```javascript
const qs = require('qs');
const data = qs.stringify({
fid_list: JSON.stringify([12345]),
schannel: 0,
channel_list: '[]',
period: 0,
public: 1
});
const resp = await client.post('/share/pset', data, {
params: { jsToken: 'TOKEN' }
});
console.log("Short URL:", resp.data.shorturl);
```
List Shares
Endpoint: GET /share/teratransfer/sharelist
Retrieves a paginated list of all active shares created by your account.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
app_id |
string | Yes | 250528. |
jsToken |
string | Yes | Session token. |
page |
int | No | Page number. Default 1. |
page_size |
int | No | Items per page. Default 100. |
Code Examples
=== "cURL"
```bash
curl "https://1024terabox.com/share/teratransfer/sharelist?app_id=250528&web=1&page=1&page_size=100&jsToken=TOKEN" \
-H "Cookie: ndus=YOUR_COOKIE"
```
=== "Python"
```python
params = {
'app_id': '250528',
'web': '1',
'page': '1',
'page_size': '100',
'jsToken': js_token
}
resp = session.get('https://1024terabox.com/share/teratransfer/sharelist', params=params)
shares = resp.json().get('data', {}).get('share_list', [])
for share in shares:
print(f"ID: {share['share_id']} | Link: {share['shorturl']}")
```
=== "Node.js"
```javascript
const resp = await client.get('/share/teratransfer/sharelist', {
params: {
app_id: '250528',
web: 1,
page: 1,
page_size: 100,
jsToken: 'TOKEN'
}
});
const shares = resp.data.data.share_list || [];
console.log(shares);
```
Cancel Share
Endpoint: POST /share/cancel
Revokes a shared link. The files are not deleted from your drive, but the public link will stop working.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
bdstoken |
string | Yes | Required for write operation. |
Body Data:
* shareid_list: JSON array of Share IDs (integers) to cancel.
Code Examples
=== "cURL"
```bash
curl -X POST "https://1024terabox.com/share/cancel?bdstoken=TOKEN" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "shareid_list=[123456]"
```
=== "Python"
```python
share_ids = [123456, 789012]
data = {
'shareid_list': json.dumps(share_ids)
}
session.post('https://1024terabox.com/share/cancel', params={'bdstoken': bdstoken}, data=data)
```
=== "Node.js"
```javascript
const data = qs.stringify({
shareid_list: JSON.stringify([123456])
});
await client.post('/share/cancel', data, {
params: { bdstoken: 'TOKEN' }
});
```