MayaPix MayaPix

API Documentation

Simple, powerful image processing. Get started in minutes.

Postman Collection
curl -X POST https://mail.mayapix.io/public/api/v1/images/process \
  -H "X-API-Key: YOUR_KEY.YOUR_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://example.com/photo.jpg",
    "operations": [{"type": "compress", "preset": "mayaai"}]
  }'
🌟

Parameter Wizard

INTERACTIVE

Answer a few questions and get your perfect API call - no docs reading needed.

Step 1 of 4 0%

🔍 What kind of images are you processing?

Authentication

Include your API key in every request using one of these methods:

Header: X-API-Key: mpx_xxxxx.your_secret

Or: Authorization: Bearer mpx_xxxxx.your_secret

Important: Never share your API key. Create separate keys for each integration.

Limits & Policies

File Limits

  • Max file size: 20 MB
  • Max dimensions: 8000 x 8000 px
  • Formats: JPEG, PNG, WebP, GIF

Data Retention

  • Image storage: 7 days
  • Job records: 30 days
  • Usage logs: 90 days

Rate Limits by Plan

Plan Requests/min Monthly Images
Free1050
Starter601,000
Pro2005,000
Business50020,000
EnterpriseCustomUnlimited

MayaAI - Recommended

One call does everything. No tuning required.

Detects the subject, removes whitespace (and optionally the background), scales appropriately, adds breathing room, and outputs a compressed WebP. Start here, fall back to Advanced Operations only if you need precise control.

Defaults when you don't specify a param

Output sizeSubject's natural size + 5% breathing room on each side
Canvas colorWhite ffffff
Output formatWebP. Override with "format": "jpeg" for legacy systems
BG removalOn by default. Set "remove_bg": false to disable. Free plan: silently skipped, no error.
UpscalingOff by default. Auto-enabled when size is set. Override with "upscale": false

Core Parameters

ParameterDefaultDescription
remove_bgtrueRemove background. Free plan: silently skipped (no error). Set false if BG is already clean
sizenoneForce square canvas (e.g. 1000 → 1000×1000). Subject scales to fill. Omit for natural size output
backgroundffffffCanvas fill color (hex, no #) or "transparent" for alpha output - auto-outputs PNG
formatwebpOutput format: webp, jpeg, png

Common Scenarios

// 1. Default - BG removal on, natural subject size + 5% breathing room
{"type": "mayaai"}

// 2. Catalog normalization - 1000×1000, subject fills canvas
{"type": "mayaai", "size": 1000}

// 3. Transparent cut-out PNG (no background at all)
{"type": "mayaai", "background": "transparent"}

// 4. Transparent cut-out, 1000×1000
{"type": "mayaai", "background": "transparent", "size": 1000}

// 5. Custom canvas color (light gray studio look)
{"type": "mayaai", "size": 1000, "background": "f5f5f5"}

// 6. Disable BG removal (image already has clean background)
{"type": "mayaai", "remove_bg": false}

Advanced MayaAI Parameters (most users never need these)

ParameterDefaultDescription
upscaleautoWhen size is set, defaults to true (fill canvas). Set false to center small subjects without scaling them up
padding5Breathing room as % of canvas each side (0–25). 5% = 50px on a 1000px canvas
modelisnet-general-useBG removal model. Use "auto" for smart detection. See model guide below
width + heightnoneNon-square canvas. e.g. "width": 1200, "height": 628. Overrides size
tolerance20How aggressively to detect solid backgrounds (0–100). Increase for off-white or gradient BGs
face_centerfalseDetect faces/models and bias subject placement toward the canvas center
target_size_kb300Target output size for smart compression (10–5000 KB)
quality_floor70Minimum quality % for smart compression (1–100)
skip_compressed_thresholddisabledSkip images already compressed below this bytes-per-pixel value (e.g., 0.3). Useful for bulk syncs. 0 or omitted = disabled
watermarkfalseAdd a brand watermark
watermark_textnoneText watermark when watermark is true
watermark_image_urlnoneLogo URL watermark when watermark is true and text is empty
// size + upscale:false → fixed canvas, small subjects centered (not blown up)
{"type": "mayaai", "size": 1000, "upscale": false}

// Custom non-square canvas
{"type": "mayaai", "width": 1200, "height": 628}

// Tighter padding (2% each side)
{"type": "mayaai", "padding": 2}

// Maximum quality BG removal (slower)
{"type": "mayaai", "remove_bg": true, "model": "birefnet-general"}

// Product on off-white background - raise tolerance
{"type": "mayaai", "tolerance": 40}

// Smart mode: auto-detect model, padding, and background
{"type": "mayaai", "smart": true}

// Auto-detect only the background removal model
{"type": "mayaai", "model": "auto"}

When smart: true or model: "auto" is set, MayaAI analyzes the image and picks defaults for the subject. Any explicit parameter you provide still overrides the smart defaults.

How MayaAI Works

🔍
Tight-crop

Finds the subject bounding box and removes surrounding whitespace

📐
Scale

Scales to fit the canvas. No upscale by default; fills canvas when size is set

🖼
Pad

Centers subject on canvas with consistent breathing room on all sides

🤖
Smart compress

AI picks optimal WebP quality per image (60–90% smaller)

Runs entirely on our servers - no third-party APIs, no per-image fees passed to you, your images never leave our infrastructure.

Process Single Image

POST /api/v1/images/process

Request Body

Field Type Required Description
image_urlstringYes*URL of image to process
imagestringYes*Base64 encoded image
operationsarrayYesList of operations
webhook_urlstringNoCallback URL for completion

* One of image_url or image is required

Base64 Example

{
  "image": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD...",
  "operations": [
    {"type": "mayaai", "size": 1000}
  ]
}

The image field accepts a raw base64 string or a data URI (data:image/png;base64,...). Max 20 MB after decoding.

Defaults at a Glance

If you omit a parameter, these values are used:

ParameterDefaultNotes
formatwebpcompress keeps the original format unless you specify one
remove_bgtrueSilently skipped on the Free plan
modelisnet-general-useUse "auto" for smart detection
backgroundffffffWhite canvas. Use "transparent" for PNG with alpha
padding55% of canvas on each side
target_size_kb300MayaAI smart compression target
quality_floor70MayaAI never compresses below this
fitcontainResize preserves aspect ratio
upscalefalseSmall images are not enlarged unless requested
positioncenterStandard crop starts from center
watermarkfalseNo watermark unless enabled

Batch Processing

POST /api/v1/images/batch

Process multiple images in a single request.

{
  "images": [
    {
      "image_url": "https://example.com/photo1.jpg",
      "operations": [{"type": "compress", "preset": "mayaai"}]
    },
    {
      "image_url": "https://example.com/photo2.jpg",
      "operations": [{"type": "resize", "width": 800}]
    }
  ],
  "webhook_url": "https://yoursite.com/webhook"
}

Job Status & Download

GET /api/v1/jobs/{job_id}

Get job status and result details

GET /api/v1/jobs/{job_id}/download

Download the processed image file

Check Usage

GET /api/v1/usage

{
  "plan": "pro",
  "period": "2024-01",
  "images_processed": 1523,
  "monthly_limit": 5000,
  "remaining": 3477,
  "resets_at": "2024-02-01T00:00:00Z"
}

Advanced Operations

Use these when MayaAI doesn’t fit your exact need, or to build custom pipelines. Operations run in order.

Compress

Reduce file size. Does not change dimensions (except presets that include a max size - see table).

Defaults: quality = 85, format = keeps original format

Parameter Default Description
quality851–100. Lower = smaller file
formatoriginaljpeg, png, webp, gif. Omit to keep original format
presetnonePre-configured shortcut. Overrides quality + format. See table below

⚠️ What presets actually do - read before using

PresetFormatQualityMax SizeNotes
mayaaiWebPAI-selectedNo resizeBest for all images. Adapts per image
ecommerceWebP851200pxScales DOWN if larger than 1200px
thumbnailWebP75300pxScales DOWN to max 300px
highqualityPNG952400pxScales DOWN to max 2400px
socialJPEG801200×630Cover-crops to 1200×630. Pair with resize first
mobileWebP70640pxScales DOWN to max 640px
catalogWebP80800pxScales DOWN to max 800px
// AI picks quality, outputs WebP, no resize
{"type": "compress", "preset": "mayaai"}

// Custom quality, convert to WebP
{"type": "compress", "quality": 75, "format": "webp"}

// Custom quality, keep original format (omit format param)
{"type": "compress", "quality": 80}

Resize

Change dimensions. Does not crop - use crop for that.

Defaults: fit = contain, upscale = false (small images stay small)

ParameterDefaultDescription
widthnoneTarget width (1–8000). Provide at least one dimension
heightnoneTarget height (1–8000). Provide at least one dimension
fitcontainHow to handle aspect ratio. See fit modes below
backgroundffffffFill color for contain / fill padding
upscalefalseAllow enlarging images smaller than target

Fit Modes

ModeBehaviorDistorts?Crops?
containFits inside box, adds padding if neededNoNo
coverFills box completely, crops overflowNoYes
fillFills box with padding around contentNoNo
maxScales down to max dimension, keeps aspectNoNo
stretchForces exact dimensionsYesNo
// Scale down to max 800px wide (default: no upscale, keeps aspect ratio)
{"type": "resize", "width": 800}

// Fit inside 1000×1000 box with white padding (no crop, no distort)
{"type": "resize", "width": 1000, "height": 1000, "fit": "contain", "background": "ffffff"}

// Fill 800×600, crop overflow (good for hero images / covers)
{"type": "resize", "width": 800, "height": 600, "fit": "cover"}

// Allow upscaling small images
{"type": "resize", "width": 1200, "upscale": true}

Crop Operation

Cut out a portion of the image, or use smart_pad mode to auto-detect the product and center it with consistent margins.

Standard Crop

Parameter Type Default Description
widthintnoneCrop width
heightintnoneCrop height
positionstringcenterWhere to crop from: center, top-left, top-right, etc.
x, yintnoneExact pixel start position
aspect_ratiostringnonee.g. "1:1", "16:9" - crops to ratio
{"type": "crop", "width": 500, "height": 500, "position": "center"}
{"type": "crop", "width": 300, "height": 300, "x": 100, "y": 50}
{"type": "crop", "aspect_ratio": "1:1"}

Smart Pad New

Auto-detects the product bounding box, trims the background, and re-pads with a consistent margin on all sides. Perfect for uniform product grids.

Parameter Type Default Description
modestringrequiredSet to "smart_pad" to enable
paddingfloat10Margin as % of content size on each side (0–50)
backgroundstringautoBackground hex color e.g. "ffffff". Auto-detected from corners if omitted
toleranceint20Color distance threshold (0–100). Increase for noisy/gradient backgrounds
width, heightintnoneOptional output size after padding (keeps aspect ratio)
// Auto-detect background, 10% margin, resize to 800×800
{"type": "crop", "mode": "smart_pad", "padding": 10, "width": 800, "height": 800}

// Explicit white background, tighter margin
{"type": "crop", "mode": "smart_pad", "background": "ffffff", "padding": 5, "tolerance": 15}

// Off-white / gradient background (raise tolerance)
{"type": "crop", "mode": "smart_pad", "padding": 10, "tolerance": 40}

Remove Background

Local AI background removal powered by rembg. Creates transparent PNG. Choose from 8 models for different use cases.

🎯 Local AI, Not Remove.bg

Runs entirely on our servers - no per-image API fees. Same quality as paid services at a fraction of the cost.

Plan Required: Starter and above. GIF images are not supported.

Parameters

Parameter Type Default Description
typestringrequired"remove_background"
modelstringisnet-general-useAI model to use (see table below)

Model Options

Model Best For Speed Quality
isnet-general-useDefault - products, objects, general useFast★★★★
u2netSolid backgrounds, legacyFast★★★
u2netpSpeed-critical use casesFastest★★
siluetaFast silhouettesFast★★★
u2net_human_segPeople, portraitsFast★★★★
u2net_cloth_segClothing itemsFast★★★
isnet-animeAnime, illustrationsFast★★★★
birefnet-generalHair, glass, fur - maximum qualitySlow★★★★★

Examples

// Default (best balance)
{"type": "remove_background"}

// Maximum quality for complex subjects (hair, fur, glass)
{"type": "remove_background", "model": "birefnet-general"}

// Optimized for human portraits
{"type": "remove_background", "model": "u2net_human_seg"}

// ⭐ Recommended: MayaAI all-in-one (bg removal + resize + compress in one call)
{"type": "mayaai", "remove_bg": true, "background": "ffffff"}

// Manual pipeline: remove background then compress
{
  "image_url": "https://example.com/product.jpg",
  "operations": [
    {"type": "remove_background"},
    {"type": "compress", "preset": "ecommerce"}
  ]
}

Recipes

Ready-made operation chains for common use cases. Copy, paste, send.

🛒 E-commerce (Full pipeline - one call)

BG removal + 1000×1000 white canvas + WebP. BG removal is on by default.

{"image_url": "...", "operations": [{"type": "mayaai", "size": 1000}]}

🧥 Fashion / Clothing (Clothing-specific model)

Use model: u2net_cloth_seg for cleaner cuts on fabric edges. MayaAI handles the rest.

{"image_url": "...", "operations": [{"type": "mayaai", "model": "u2net_cloth_seg", "size": 1000}]}

📱 Social Media (Instagram / LinkedIn)

Square 1080×1080, center-cropped, JPEG

{"image_url": "...", "operations": [
  {"type": "resize", "width": 1080, "height": 1080, "fit": "cover"},
  {"type": "compress", "quality": 85, "format": "jpeg"}
]}

🖼 Blog / Article Hero

1200×630 for Open Graph / social preview

{"image_url": "...", "operations": [
  {"type": "resize", "width": 1200, "height": 630, "fit": "cover"},
  {"type": "compress", "quality": 85, "format": "webp"}
]}

🗜 Just Compress (no resize, no format change)

Reduce file size only, keep everything else

{"image_url": "...", "operations": [{"type": "compress", "quality": 80}]}

🎯 High-quality Cut-out (hair, glass, fur)

birefnet-general is the highest quality model (slower). background: transparent preserves the alpha channel as PNG.

{"image_url": "...", "operations": [{"type": "mayaai", "model": "birefnet-general", "background": "transparent"}]}

Salla Embedded Integration

Endpoints used by the Salla embedded app. Include the Salla token in the Authorization: Bearer <salla_token> header.

Get Store Settings

GET /api/v1/integrations/salla/settings

Returns the merchant's saved settings, store info, Salla subscription status, and the linked MayaPix plan/usage (monthly remaining images).

The response includes both the Salla billing cycle (subscription.ends_at) and the calendar-month quota reset (usage.resets_at).

Save Store Settings

POST /api/v1/integrations/salla/settings

Save the embedded app settings. Example body:

{
  "settings": {
    "auto_process": true,
    "bg_removal": true,
    "bg_model": "isnet-general-use",
    "canvas_size": "1:1",
    "canvas_width": null,
    "canvas_height": null,
    "output_format": "webp",
    "compression_quality": 85,
    "padding_color": "#FFFFFF",
    "padding": 5,
    "smart_quality": true,
    "target_size_kb": 300,
    "quality_floor": 70,
    "skip_compressed_threshold": 0,
    "face_center": false,
    "watermark": false,
    "watermark_text": "",
    "keep_original": false
  }
}

Canvas size: choose "1:1", "4:3", "16:9", "original", or "custom". For custom, set canvas_width and canvas_height to positive pixel values.

Keep originals: when enabled, a backup of every original image is stored in the originals/ path for 7 days. Restore is manual only; there is no automatic restore endpoint.

Background model: bg_model sets the AI model used when bg_removal is true. Options: isnet-general-use (default), u2net_cloth_seg (fashion), u2net_human_seg (people), birefnet-general (best quality, slower).

Recommend Settings with AI

POST /api/v1/integrations/salla/recommend-settings

Upload 1-5 sample product images and receive a recommended preset and settings tuned for your store.

curl -X POST https://mail.mayapix.io/public/api/v1/integrations/salla/recommend-settings \
  -H "Authorization: Bearer <salla_token>" \
  -F "images[]=@product1.jpg" \
  -F "images[]=@product2.jpg"

Subscription Webhooks

POST /api/v1/webhooks/salla

Salla sends subscription events to this endpoint. MayaPix keeps the linked plan in sync automatically.

app.subscription.started app.subscription.renewed app.subscription.canceled app.subscription.expired app.trial.started app.trial.canceled app.trial.expired

Plan names are mapped to MayaPix slugs via config/services.salla.plan_map. Unknown names fall back to free.

Upload Brand Logo

POST /api/v1/integrations/salla/logo

Upload a brand logo for watermark. Send as multipart/form-data with a logo file (PNG/JPEG/WebP, max 2MB).

curl -X POST https://mail.mayapix.io/public/api/v1/integrations/salla/logo \
  -H "Authorization: Bearer <salla_token>" \
  -F "logo=@logo.png"

Webhooks

Two ways to receive job notifications - pick the one that fits your workflow.

Method 1: Ad-hoc webhook_url

Pass a URL directly in the process request. Simple, one-time, no setup needed. No HMAC signing.

{
  "image_url": "https://example.com/photo.jpg",
  "operations": [{"type": "mayaai"}],
  "webhook_url": "https://your-site.com/hook"
}

Method 2: Registered Webhooks (CRUD)

Register a persistent endpoint that fires for all matching jobs. HMAC-signed, supports event filtering, auto-disables after 10 consecutive failures.

GET /api/v1/webhooks - list all registered webhooks
POST /api/v1/webhooks - register a new webhook
PUT /api/v1/webhooks/{id} - update url, events, or active state
POST /api/v1/webhooks/{id}/test - send a test ping to verify your endpoint
POST /api/v1/webhooks/{id}/regenerate-secret - rotate HMAC signing secret
DELETE /api/v1/webhooks/{id} - remove a webhook (max 10 per account)

Events

job.completed job.failed batch.completed

Verifying the signature

Each registered webhook delivery includes an X-MayaPix-Signature header. Verify it to confirm the request came from MayaPix.

// PHP example
$signature = hash_hmac('sha256', json_encode($payload), $webhookSecret);
if (!hash_equals($signature, $request->header('X-MayaPix-Signature'))) {
    abort(401);
}

Payload format

{
  "event": "job.completed",
  "job_id": "550e8400-e29b-41d4...",
  "status": "completed",
  "result": {
    "download_url": "https://...",
    "size": 245760,
    "width": 1600,
    "height": 1200
  }
}

Error Codes

Code Meaning
200Success
202Job queued (processing)
400Bad request - check parameters
401Invalid API key
402Quota exceeded - upgrade plan
403Feature not on your plan
404Job not found
429Rate limit - slow down
500Server error - contact support

Need Help?

Need help? Contact our support team.

Get Your API Key