Skip to main content
The /resume endpoint allows you to resume a paused download. The download will continue from the exact position where it was paused.

POST /resume

Resume a previously paused download.

Query Parameters

id
string
required
The unique download ID to resume. This is the ID returned when the download was created.

Request

curl -X POST "http://localhost:1700/resume?id=550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response

Returns a JSON object confirming the resume operation:
status
string
Confirmation that the download was resumed. Always returns "resumed".
id
string
The ID of the resumed download.

Response Example

{
  "status": "resumed",
  "id": "550e8400-e29b-41d4-a716-446655440000"
}

Examples

curl -X POST "http://localhost:1700/resume?id=550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer YOUR_TOKEN"

Behavior

When you resume a download:
  1. State restored: The saved download state is loaded from disk
  2. Connections re-established: New connections are opened to the server(s)
  3. Progress continues: Download continues from the exact byte where it was paused
  4. Integrity verified: Surge verifies the partial file hasn’t been corrupted
Surge automatically resumes paused downloads when the server starts, unless you use the --no-resume flag.

Resuming Multiple Downloads

To resume multiple downloads, you need to make separate API calls for each download ID:
const downloadIds = [
  '550e8400-e29b-41d4-a716-446655440000',
  '660e8400-e29b-41d4-a716-446655440001',
  '770e8400-e29b-41d4-a716-446655440002'
];

for (const id of downloadIds) {
  await fetch(`http://localhost:1700/resume?id=${id}`, {
    method: 'POST',
    headers: { 'Authorization': 'Bearer YOUR_TOKEN' }
  });
}

Auto-Resume on Server Start

By default, Surge automatically resumes all paused downloads when the server starts:
# Default behavior - auto-resumes paused downloads
surge server
To disable auto-resume:
# Paused downloads remain paused until manually resumed
surge server --no-resume

Error Responses

Resume Workflow Example

Here’s a complete workflow showing pause and resume:
// Start a download
const startResponse = await fetch('http://localhost:1700/download', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ url: 'https://example.com/large-file.zip' })
});

const { id } = await startResponse.json();

// Wait for some progress...
await new Promise(resolve => setTimeout(resolve, 5000));

// Pause the download
await fetch(`http://localhost:1700/pause?id=${id}`, {
  method: 'POST',
  headers: { 'Authorization': 'Bearer YOUR_TOKEN' }
});

console.log('Download paused');

// Later... resume the download
await fetch(`http://localhost:1700/resume?id=${id}`, {
  method: 'POST',
  headers: { 'Authorization': 'Bearer YOUR_TOKEN' }
});

console.log('Download resumed');

Use Cases

  • Network Recovery: Resume downloads after network interruption
  • Scheduled Downloads: Resume downloads during off-peak hours
  • Resource Management: Resume when system resources become available
  • User Control: Let users manually resume downloads through a UI
  • Batch Operations: Resume multiple downloads programmatically
  • Pause - Pause an active download
  • List - Check which downloads are paused
  • Events - Receive real-time resume notifications