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 URL | https://api.easebg.com/api/v1 |
| Local Development | http://localhost:3001/api/v1 |
| Authentication | X-API-Key Header |
| Response Format | JSON |
| Character Encoding | UTF-8 |
Quick Start
Complete your first background removal in 3 steps:
Get Your API Key
Create an API Key in the Developer Center for request authentication.
Create a Task
Submit an image URL to create a background removal task:
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"}'
Get the Result
Query the task status and download the result from resultUrl when complete:
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:
| Caller | Method | Header | Path 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/* |
Task Processing Flow
The complete flow from upload to result retrieval:
Task Status Flow
Upload Images
EaseBG supports two image upload methods:
{
"imageUrl": "https://example.com/photo.jpg"
}
# 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
| Format | MIME Type | Max Size |
|---|---|---|
| PNG | image/png | 20 MB |
| JPEG | image/jpeg | 20 MB |
| WebP | image/webp | 20 MB |
Create Task
Submit an image URL to create a background removal task:
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
| Parameter | Type | Required | Description |
|---|---|---|---|
imageUrl | string (uri) | Yes | Image URL to process |
modelVersion | string | No | Model version, defaults to latest |
callbackUrl | string (uri) | No | Webhook callback URL |
metadata | object | No | Custom 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 "https://api.easebg.com/api/v1/open/developer/tasks/TASK_ID" \
-H "X-API-Key: YOUR_API_KEY"
Response Example (Processing)
{
"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)
{
"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:
// 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();
});
?token= query parameter authentication instead of withCredentials, because the browser EventSource API does not support custom headers.
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.
# 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 "https://api.easebg.com/api/v1/app/tasks/images/TASK_ID/download" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
Tasks API
Image processing task endpoints, supporting creation, querying, cancellation, and retry.
/open/developer/tasks
Tasks
Create Background Removal Task
Submit an image for background removal. Supports both synchronous waiting and async callback modes.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
imageUrl | string (uri) | Yes | Image URL to process |
modelVersion | string | No | Model version, defaults to latest |
callbackUrl | string (uri) | No | Webhook callback URL |
metadata | object | No | Custom metadata |
Response Example
{
"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
| HTTP | Error Code | Description |
|---|---|---|
| 400 | INVALID_PARAMS | Invalid request parameters |
| 401 | INVALID_API_KEY | Invalid API key |
| 402 | INSUFFICIENT_CREDITS | Insufficient credits |
| 429 | RATE_LIMIT_EXCEEDED | Rate limit exceeded |
/open/developer/tasks
Tasks
List Tasks
Get the task list for the current API user, supporting pagination and status filtering.
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
page | integer | 1 | Page number |
pageSize | integer | 20 | Items per page, max 100 |
status | string | - | Filter: queued, processing, succeeded, failed, canceled |
startDate | date | - | Start date |
endDate | date | - | End date |
/open/developer/tasks/{taskId}
Tasks
Get Task Details
Get task details by ID, including the result URL.
/open/developer/tasks/{taskId}
Tasks
Cancel Task
Cancel a queued task. Completed or processing tasks cannot be canceled.
/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.
/open/developer/batch-tasks
Batch
Create Batch Task
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
imageUrls | string[] (uri) | Yes | Array of image URLs, max 50 |
modelVersion | string | No | Model version |
callbackUrl | string (uri) | No | Webhook callback URL |
/open/developer/batch-tasks
Batch
List Batch Tasks
/open/developer/batch-tasks/{batchId}
Batch
Get Batch Task Details
Webhooks API
/open/developer/webhooks
Webhook
List Webhook Endpoints
/open/developer/webhooks
Webhook
Create Webhook Endpoint
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string (uri) | Yes | Webhook receiver URL |
events | string[] | Yes | List of subscribed events |
Developer API
/open/developer/api-keys
Developer
List API Keys
/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
| Parameter | Type | Description |
|---|---|---|
startDate | date | Start date |
endDate | date | End date |
App API Reference
Frontend-facing endpoints for Web/App, using JWT Bearer Token authentication.
| Module | Path Prefix | Key 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 |
openapi-app.json for the complete App API contract.
Admin API Reference
Backend management endpoints, using JWT + 2FA authentication.
| Module | Path Prefix | Key Endpoints |
|---|---|---|
| Auth | /admin/auth/* | Admin login, 2FA, Password |
| Dashboard | /admin/dashboard | Overview |
| 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 |
openapi-admin.json for the complete Admin API contract.
Internal API Reference
Internal service endpoints (inference, storage, nodes), using Internal Token authentication.
X-Internal-Token is not leaked.
| Module | Path | Description |
|---|---|---|
| Task Status | POST /internal/tasks/:jobId/status | Write back status after inference completes |
| Task Progress | POST /internal/tasks/:jobId/progress | Worker node reports progress |
| Task Callback | POST /internal/tasks/callback | Full inference service callback |
| Node Register | POST /internal/worker/register | Worker node registration on startup |
| Node Heartbeat | POST /internal/nodes/heartbeat | Inference node heartbeat |
| Node Metrics | POST /internal/nodes/metrics | Inference node metrics report |
| Config Read | GET /internal/config/:key | Internal service reads system config |
| Payment Callback | POST /internal/payments/:orderId/success | Payment gateway success callback |
| Refund Callback | POST /internal/refunds/:refundId/completed | Refund completion callback |
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.
eventId for idempotent processing.
Request Format
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
| Event | Trigger | Payload 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
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')
);
}
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:
| Attempt | Delay | Cumulative |
|---|---|---|
| 1st | 30s | 30s |
| 2nd | 2 min | 2 min 30s |
| 3rd | 10 min | 12 min 30s |
| 4th | 1 hour | 1 hr 12 min 30s |
| 5th | 6 hours | 7 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
- Log in to the Developer Center and navigate to the Webhook management page
- View delivery records and filter for
failedevents - 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-Signatureheader matches your locally computed signature - Ensure your server returns a
200status code, otherwise retries will be triggered - Use
eventIdfor idempotent processing to avoid handling the same event twice
Idempotency Example
// 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:
{
"request_id": "req_abc123",
"error": {
"code": "TASK_NOT_FOUND",
"message": "Task not found",
"details": {}
}
}
| HTTP | Error Code | Description |
|---|---|---|
| 400 | INVALID_PARAMS | Invalid request parameters |
| 401 | INVALID_API_KEY | Invalid or missing API key |
| 401 | INVALID_TOKEN | Invalid or expired JWT token |
| 402 | INSUFFICIENT_CREDITS | Insufficient credits |
| 403 | FORBIDDEN | Access forbidden |
| 404 | TASK_NOT_FOUND | Task not found |
| 404 | RESOURCE_NOT_FOUND | Resource not found |
| 409 | CONFLICT | State conflict |
| 429 | RATE_LIMIT_EXCEEDED | Rate limit exceeded |
| 500 | INTERNAL_ERROR | Internal server error |
| 503 | SERVICE_UNAVAILABLE | Service temporarily unavailable |
Rate Limits
API request rates are tiered by plan:
| Plan | Requests/min | Concurrent Tasks | Batch Limit |
|---|---|---|---|
| Free | 10 | 1 | 5 |
| Pro | 60 | 5 | 20 |
| Team | 200 | 20 | 50 |
| Enterprise | 1000 | 100 | 50 |
When the limit is exceeded, a 429 status code is returned with the following 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
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)
Deprecated
- Legacy
/v1/tasksendpoints marked as deprecated
Deprecated APIs
| Deprecated | Replacement | Since | Removal |
|---|---|---|---|
GET /v1/tasks | GET /api/v1/open/developer/tasks | v2.0 | v3.0 |
POST /v1/tasks | POST /api/v1/open/developer/tasks | v2.0 | v3.0 |
GET /v1/tasks/{id} | GET /api/v1/open/developer/tasks/{taskId} | v2.0 | v3.0 |
DELETE /v1/tasks/{id} | DELETE /api/v1/open/developer/tasks/{taskId} | v2.0 | v3.0 |