EaseBG API

AI Background Removal SaaS Platform — Developer API Documentation

High-Performance Inference

Powered by EaseBG v2 model, average processing time < 2 seconds

📦

Batch Processing

Support up to 50 images per batch for background removal

🔔

Webhook Callbacks

Async task completion notifications with HMAC-SHA256 signature verification

🌐

Multi-Language SDKs

cURL, JavaScript, Python, Go, Java, PHP, Ruby, C#

Basic Information

Base URLhttps://api.easebg.com/api/v1
Local Developmenthttp://localhost:3001/api/v1
AuthenticationX-API-Key Header
Response FormatJSON
Character EncodingUTF-8

Quick Start

Complete your first background removal in 3 steps:

1

Get Your API Key

Create an API Key in the Developer Center for request authentication.

2

Create a Task

Submit an image URL to create a background removal task:

cURL
curl -X POST "https://api.easebg.com/api/v1/open/developer/tasks" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"imageUrl": "https://example.com/photo.jpg"}'
3

Get the Result

Query the task status and download the result from resultUrl when complete:

cURL
curl "https://api.easebg.com/api/v1/open/developer/tasks/TASK_ID" \
  -H "X-API-Key: YOUR_API_KEY"

Authentication

EaseBG API supports multiple authentication methods depending on the caller:

CallerMethodHeaderPath Prefix
External Developers API Key X-API-Key: easebg_live_xxx /open/developer/*
Web/App Frontend JWT Bearer Token Authorization: Bearer eyJ... /app/*
Admin Backend JWT + 2FA Authorization: Bearer eyJ... /admin/*
Internal Services Internal Token X-Internal-Token: xxx /internal/*
Note: Keep your API Key secure and never expose it in frontend code. Use environment variables for management.

Task Processing Flow

The complete flow from upload to result retrieval:

📤
Upload Image
📝
Create Task
Queue & Process
🔧
AI Inference
Get Result

Task Status Flow

queued processing succeeded or failed

Upload Images

EaseBG supports two image upload methods:

Method 1: Provide an image URL directly (recommended for server-side integration)
JSON
{
  "imageUrl": "https://example.com/photo.jpg"
}
Method 2: Upload to object storage via presigned URL (recommended for browser/app direct upload)
cURL
# Step 1: Get a presigned upload URL
curl -X POST "https://api.easebg.com/api/v1/app/tasks/uploads/presign" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"fileName": "photo.jpg", "contentType": "image/jpeg"}'

# Step 2: Upload the file using the returned uploadUrl
curl -X PUT "RETURNED_UPLOAD_URL" \
  -H "Content-Type: image/jpeg" \
  --data-binary @photo.jpg

Supported Image Formats

FormatMIME TypeMax Size
PNGimage/png20 MB
JPEGimage/jpeg20 MB
WebPimage/webp20 MB

Create Task

Submit an image URL to create a background removal task:

cURL
curl -X POST "https://api.easebg.com/api/v1/open/developer/tasks" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "imageUrl": "https://example.com/photo.jpg",
    "modelVersion": "easebg-2.0",
    "callbackUrl": "https://your-app.com/webhooks/easebg"
  }'

Request Parameters

ParameterTypeRequiredDescription
imageUrlstring (uri)YesImage URL to process
modelVersionstringNoModel version, defaults to latest
callbackUrlstring (uri)NoWebhook callback URL
metadataobjectNoCustom metadata

Sync vs Async

By default, tasks run in async mode and return a queued status immediately. For synchronous waiting, poll GET /tasks/{taskId} or configure a webhook callback for completion notifications.

Query Task

Query processing status and results by task ID:

cURL
curl "https://api.easebg.com/api/v1/open/developer/tasks/TASK_ID" \
  -H "X-API-Key: YOUR_API_KEY"

Response Example (Processing)

JSON
{
  "request_id": "req_abc123",
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "status": "processing",
    "modelVersion": "easebg-2.0",
    "sourceUrl": "https://example.com/photo.jpg",
    "resultUrl": null,
    "createdAt": "2025-01-15T10:30:00Z",
    "completedAt": null
  }
}

Response Example (Completed)

JSON
{
  "request_id": "req_abc123",
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "status": "succeeded",
    "modelVersion": "easebg-2.0",
    "sourceUrl": "https://example.com/photo.jpg",
    "resultUrl": "https://storage.easebg.com/results/550e8400.png",
    "durationMs": 1200,
    "createdAt": "2025-01-15T10:30:00Z",
    "completedAt": "2025-01-15T10:30:01.2Z"
  }
}

SSE Real-Time Stream

For App/Web frontend, use SSE (Server-Sent Events) to receive real-time task progress:

JavaScript
// SSE connection (authenticate via token query parameter)
const eventSource = new EventSource(
  `https://api.easebg.com/api/v1/app/tasks/images/${taskId}/stream?token=${accessToken}`
);

eventSource.addEventListener('progress', (e) => {
  console.log('Progress:', JSON.parse(e.data));
});

eventSource.addEventListener('completed', (e) => {
  console.log('Completed:', JSON.parse(e.data));
  eventSource.close();
});

eventSource.addEventListener('failed', (e) => {
  console.error('Failed:', JSON.parse(e.data));
  eventSource.close();
});
Note: SSE connections use ?token= query parameter authentication instead of withCredentials, because the browser EventSource API does not support custom headers.
Alternative: To retrieve event logs during task processing, call GET /api/v1/app/tasks/images/{taskId}/events for event history, supporting polling mode.

Download Result

After task completion, retrieve the result via the following methods:

Method 1: Direct from Response

When querying task details, the resultUrl field contains the result image URL for direct download.

cURL
# Download the result image
curl -o result.png "https://storage.easebg.com/results/550e8400.png"

Method 2: Get Download URL (App API)

For App/Web frontend, use the dedicated download endpoint to get a time-limited download URL:

cURL
curl "https://api.easebg.com/api/v1/app/tasks/images/TASK_ID/download" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
Validity: The result URL is valid for 7 days. Call the API again to regenerate after expiration.

Tasks API

Image processing task endpoints, supporting creation, querying, cancellation, and retry.

POST /open/developer/tasks Tasks

Create Background Removal Task

Submit an image for background removal. Supports both synchronous waiting and async callback modes.

Request Parameters

ParameterTypeRequiredDescription
imageUrlstring (uri)YesImage URL to process
modelVersionstringNoModel version, defaults to latest
callbackUrlstring (uri)NoWebhook callback URL
metadataobjectNoCustom metadata

Response Example

JSON
{
  "request_id": "req_abc123",
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "status": "queued",
    "modelVersion": "easebg-2.0",
    "sourceUrl": "https://example.com/photo.jpg",
    "resultUrl": null,
    "createdAt": "2025-01-15T10:30:00Z",
    "completedAt": null
  }
}

Error Codes

HTTPError CodeDescription
400INVALID_PARAMSInvalid request parameters
401INVALID_API_KEYInvalid API key
402INSUFFICIENT_CREDITSInsufficient credits
429RATE_LIMIT_EXCEEDEDRate limit exceeded
GET /open/developer/tasks Tasks

List Tasks

Get the task list for the current API user, supporting pagination and status filtering.

Query Parameters

ParameterTypeDefaultDescription
pageinteger1Page number
pageSizeinteger20Items per page, max 100
statusstring-Filter: queued, processing, succeeded, failed, canceled
startDatedate-Start date
endDatedate-End date
GET /open/developer/tasks/{taskId} Tasks

Get Task Details

Get task details by ID, including the result URL.

DELETE /open/developer/tasks/{taskId} Tasks

Cancel Task

Cancel a queued task. Completed or processing tasks cannot be canceled.

POST /open/developer/tasks/{taskId}/retry Tasks

Retry Task

Resubmit a failed task for processing.

Batch API

Batch processing endpoints, supporting up to 50 images per request.

POST /open/developer/batch-tasks Batch

Create Batch Task

Request Parameters

ParameterTypeRequiredDescription
imageUrlsstring[] (uri)YesArray of image URLs, max 50
modelVersionstringNoModel version
callbackUrlstring (uri)NoWebhook callback URL
GET /open/developer/batch-tasks Batch

List Batch Tasks

GET /open/developer/batch-tasks/{batchId} Batch

Get Batch Task Details

Webhooks API

GET /open/developer/webhooks Webhook

List Webhook Endpoints

POST /open/developer/webhooks Webhook

Create Webhook Endpoint

Request Parameters

ParameterTypeRequiredDescription
urlstring (uri)YesWebhook receiver URL
eventsstring[]YesList of subscribed events

Developer API

GET /open/developer/api-keys Developer

List API Keys

GET /open/developer/usage Developer

Get Usage Statistics

Get usage statistics for the current API key, including request count, task count, and credit consumption.

Query Parameters

ParameterTypeDescription
startDatedateStart date
endDatedateEnd date

App API Reference

Frontend-facing endpoints for Web/App, using JWT Bearer Token authentication.

ModulePath PrefixKey Endpoints
Auth/app/auth/*Register, Login, 2FA, Password, Email verification
User/app/users/*Profile, Subscription, Login history
Tasks/app/tasks/*Create, Query, Batch, Retry, Download
Credits/app/credits/*Balance, Ledger, Expiry alerts
Payments/app/payments/*Orders, Refunds, Invoices, Subscriptions
Notifications/app/notifications/*List, Unread count, Mark read
Referral/app/referral/*Referral info, Invitation records
Teams/app/teams/*Members, Invites, Credits, Billing
Full endpoint list: See openapi-app.json for the complete App API contract.

Admin API Reference

Backend management endpoints, using JWT + 2FA authentication.

ModulePath PrefixKey Endpoints
Auth/admin/auth/*Admin login, 2FA, Password
Dashboard/admin/dashboardOverview
User Mgmt/admin/users/*User CRUD, Tags, Status, Risk level
Plans/admin/plans/*Plans & entitlements
Credits/admin/credits/*Credit packs, Ledger, Adjustments
Payments/admin/payments/*Orders, Refunds, Reconciliation, Gateways
Tasks/admin/tasks/*Jobs, Batch, Dead-letter, Nodes, Models
Content/admin/content/*CMS pages, Coupons, Campaigns
Risk/admin/risk/*Events, Rules, Lists, Disputes
Notifications/admin/notifications/*Templates, Send logs, Retries
Support/admin/support/*Tickets & messages
System/admin/system/*Feature flags, Config, Security logs
Audit/admin/audit/*Audit logs, Data requests, Approvals
Full endpoint list: See openapi-admin.json for the complete Admin API contract.

Internal API Reference

Internal service endpoints (inference, storage, nodes), using Internal Token authentication.

Security Note: Internal API is for internal services only. Ensure X-Internal-Token is not leaked.
ModulePathDescription
Task StatusPOST /internal/tasks/:jobId/statusWrite back status after inference completes
Task ProgressPOST /internal/tasks/:jobId/progressWorker node reports progress
Task CallbackPOST /internal/tasks/callbackFull inference service callback
Node RegisterPOST /internal/worker/registerWorker node registration on startup
Node HeartbeatPOST /internal/nodes/heartbeatInference node heartbeat
Node MetricsPOST /internal/nodes/metricsInference node metrics report
Config ReadGET /internal/config/:keyInternal service reads system config
Payment CallbackPOST /internal/payments/:orderId/successPayment gateway success callback
Refund CallbackPOST /internal/refunds/:refundId/completedRefund completion callback
Full endpoint list: See openapi-internal.json for the complete Internal API contract.

Webhook Overview

When a task status changes, EaseBG sends a POST request to your configured webhook URL.

Idempotency: The same event may be delivered multiple times. Use eventId for idempotent processing.

Request Format

HTTP
POST /your-webhook-endpoint HTTP/1.1
Host: your-app.com
Content-Type: application/json
X-EaseBG-Signature: a1b2c3d4e5f6...
X-EaseBG-Event: task.succeeded

{
  "eventId": "evt_abc123",
  "event": "task.succeeded",
  "taskId": "550e8400-e29b-41d4-a716-446655440000",
  "resultUrl": "https://storage.easebg.com/results/550e8400.png",
  "timestamp": "2025-01-15T10:30:05Z"
}

Webhook Event List

EventTriggerPayload Fields
task.succeeded Task processing succeeded taskId, resultUrl, durationMs
task.failed Task processing failed taskId, errorMessage, errorCode
task.canceled Task was canceled taskId, canceledBy
batch.completed All batch tasks completed batchId, succeeded, failed
credits.low Credit balance below threshold balance, threshold

Webhook Signature Verification

Each webhook request carries an X-EaseBG-Signature header, signed using HMAC-SHA256.

Signature Algorithm

JavaScript
const crypto = require('crypto');

function verifySignature(payload, signature, secret) {
  const computed = crypto
    .createHmac('sha256', secret)
    .update(payload, 'utf8')
    .digest('hex');
  return crypto.timingSafeEqual(
    Buffer.from(computed, 'hex'),
    Buffer.from(signature, 'hex')
  );
}
Security Note: Always use a constant-time comparison function (e.g., timingSafeEqual) to verify signatures and prevent timing attacks.

Webhook Retry Strategy

If your server returns a non-2xx status code, the system retries as follows:

AttemptDelayCumulative
1st30s30s
2nd2 min2 min 30s
3rd10 min12 min 30s
4th1 hour1 hr 12 min 30s
5th6 hours7 hr 12 min 30s

After 5 retries, the event is marked as failed and can be manually replayed in the Developer Center.

Webhook Replay & Debug

In the Developer Center, you can view webhook delivery records and manually replay failed events.

How to Replay

  1. Log in to the Developer Center and navigate to the Webhook management page
  2. View delivery records and filter for failed events
  3. Click the "Replay" button to resend the event

Debug Tips

  • Use RequestBin or webhook.site as a temporary receiver for debugging
  • Verify that the X-EaseBG-Signature header matches your locally computed signature
  • Ensure your server returns a 200 status code, otherwise retries will be triggered
  • Use eventId for idempotent processing to avoid handling the same event twice

Idempotency Example

JavaScript
// Idempotent handling example
async function handleWebhook(req, res) {
  const { eventId, event, taskId } = req.body;

  // Check if event was already processed
  const exists = await db.query(
    'SELECT 1 FROM webhook_events WHERE event_id = $1',
    [eventId]
  );
  if (exists) {
    return res.status(200).json({ ok: true, message: 'already processed' });
  }

  // Process the event
  await processEvent(event, taskId);

  // Record as processed
  await db.query(
    'INSERT INTO webhook_events (event_id, event_type, task_id) VALUES ($1, $2, $3)',
    [eventId, event, taskId]
  );

  res.status(200).json({ ok: true });
}

Error Codes

All error responses use the following unified format:

JSON
{
  "request_id": "req_abc123",
  "error": {
    "code": "TASK_NOT_FOUND",
    "message": "Task not found",
    "details": {}
  }
}
HTTPError CodeDescription
400INVALID_PARAMSInvalid request parameters
401INVALID_API_KEYInvalid or missing API key
401INVALID_TOKENInvalid or expired JWT token
402INSUFFICIENT_CREDITSInsufficient credits
403FORBIDDENAccess forbidden
404TASK_NOT_FOUNDTask not found
404RESOURCE_NOT_FOUNDResource not found
409CONFLICTState conflict
429RATE_LIMIT_EXCEEDEDRate limit exceeded
500INTERNAL_ERRORInternal server error
503SERVICE_UNAVAILABLEService temporarily unavailable

Rate Limits

API request rates are tiered by plan:

PlanRequests/minConcurrent TasksBatch Limit
Free1015
Pro60520
Team2002050
Enterprise100010050

When the limit is exceeded, a 429 status code is returned with the following headers:

HTTP Headers
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1736940660
Retry-After: 60

SDK Examples

Complete example code is available in the following languages:

Postman Collection

Import the Postman collection to quickly start testing the API:

Changelog

v2.0.0
2025-07-17

Breaking Changes

  • Unified API path prefix to /api/v1
  • Layered authentication: API Key / JWT / Internal Token
  • Unified error response format
  • SSE connection method changed

New Endpoints

  • Tasks API (create, query, cancel, retry)
  • Batch API (batch processing)
  • Webhooks API (endpoint management)
  • Developer API (API Key, usage stats)
  • App API (register, login, user center, etc.)
  • Admin API (full backend management endpoints)
  • Internal API (task callback, node management)
v1.5.0
2025-03-15

Deprecated

  • Legacy /v1/tasks endpoints marked as deprecated
View Full Changelog →

Deprecated APIs

Migration Notice: The following APIs are deprecated and will be removed in v3.0. Please migrate to the new endpoints as soon as possible.
DeprecatedReplacementSinceRemoval
GET /v1/tasksGET /api/v1/open/developer/tasksv2.0v3.0
POST /v1/tasksPOST /api/v1/open/developer/tasksv2.0v3.0
GET /v1/tasks/{id}GET /api/v1/open/developer/tasks/{taskId}v2.0v3.0
DELETE /v1/tasks/{id}DELETE /api/v1/open/developer/tasks/{taskId}v2.0v3.0

EaseBG API Documentation — v2.0.0

© 2025 EaseBG. All rights reserved.

Try it out

Note: The try-it-out panel calls the real API and will consume credits.