Maileditor Docs
PluginAPI referenceEmbedded API

Stock images

Searching Unsplash, Pexels and Pixabay from the editor with the provider keys attached to your plugin.

All endpoints on this page require Authorization: Bearer {session_token} from the session endpoint and the embedded headers.

Stock search runs on your own provider keys, attached on the Stock Images tab. MailEditor holds no key of its own for a plugin, so a plugin with no key has no stock library. There is no plan feature to buy and no quota to spend; the provider sets the limits that apply to your key.

Which providers are available comes from curation.stock on bootstrap. There is no separate providers endpoint. The editor hides the Stock Images tab when providers is empty.

"stock": { "is_available": true, "providers": [{ "value": "unsplash", "label": "Unsplash" }] }

Every request names one provider in a provider field. A provider your plugin has no key for fails validation with 422, the same as a misspelled one.

Limits. 30 requests per minute and 300 per hour per session, plus 2000 per hour across the whole plugin. Import counts against the upload limit instead: 20 per minute and 200 per hour per session.

The stock image object

{
  "id": "Qwh5TL0J_7k",
  "url": "https://images.unsplash.com/photo-16…?w=600&h=400&fit=crop&crop=entropy&fm=jpg&q=80",
  "thumb_url": "https://images.unsplash.com/photo-16…?w=400",
  "alt": "a laptop on a wooden desk",
  "download_location": "https://api.unsplash.com/photos/Qwh5TL0J_7k/download",
  "credit": {
    "name": "Jane Doe",
    "link": "https://unsplash.com/@janedoe?utm_source=my-app&utm_medium=referral",
    "provider": "Unsplash",
    "provider_link": "https://unsplash.com?utm_source=my-app&utm_medium=referral"
  }
}
FieldNotes
idThe provider's own id. Unique per provider, not across them
urlThe full-size image to place in the template. Cropped to width and height when you ask for them
thumb_urlA smaller version for the picker grid
altThe provider's description, or its tags for Pixabay. Often an empty string
download_locationPass this to track a download. Empty string for Pexels and Pixabay, which have no such endpoint
credit.nameThe photographer. Empty when the provider gives none
credit.linkThe photographer's profile, with your utm_source appended
credit.provider, credit.provider_linkUnsplash, Pexels or Pixabay, and its site with the same UTM parameters

Show the credit

Unsplash and Pexels both require attribution to the photographer and to themselves, and the links must carry the UTM parameters. That is why credit.link and credit.provider_link arrive with them already appended. Render both links next to the image in the picker. The terms are yours to meet, since the key is yours.

Search stock images

GET /public/plugin/v1/stock/images?provider=unsplash&search=desk&page=1&width=600&height=400
Authorization: Bearer mep_…
QueryRequiredNotes
provideryesunsplash, pexels or pixabay, and your plugin must hold a key for it
searchnoUp to 120 characters. Omit it for the provider's editorial or curated feed
pageno1 to 100. Defaults to 1
width, heightno1 to 4000. Both or neither

width and height build a cropped, compressed url through the provider's own image CDN, so a 600x400 slot downloads a 600x400 file. Give both or you get the provider's default size back. Pixabay ignores them, because its CDN does not resize.

Page size is fixed by MailEditor and is not a parameter. Read has_more instead of counting results.

200

{
  "message": "Stock images retrieved successfully",
  "result": {
    "images": [ { "id": "Qwh5TL0J_7k", "url": "https://…", "…": "…" } ],
    "has_more": true
  }
}
Statusresult.errorMeaning
422provider missing, unknown, or not configured on this plugin. search over 120 characters, page over 100, or a dimension over 4000
502stock_provider_unavailableThe provider refused or was unreachable. A rejected key looks like this too. Check the key on the dashboard tab
429Rate limited

Track a download

Unsplash's API terms require a call to the photo's download endpoint each time a user picks the image. Pexels and Pixabay have no equivalent, so they return an empty download_location and there is nothing to send.

POST /public/plugin/v1/stock/track-download
{ "provider": "unsplash", "download_location": "https://api.unsplash.com/photos/Qwh5TL0J_7k/download" }
FieldRequiredNotes
provideryesMust hold a key on this plugin
download_locationyesCopied verbatim from the image object. Max 2048 characters

Send it when the user confirms the image, not while browsing. Fire and forget: the response carries no payload, and a provider that fails to answer is logged and swallowed, so a tracking failure never blocks the user.

200

{ "message": "Download tracked", "result": null }
Statusresult.errorMeaning
422invalid_download_locationThe URL is not one that provider can track. Only https://api.unsplash.com/photos/… is accepted, and only for unsplash. Pass the download_location you were given rather than building one
422provider or download_location missing or unknown

Import an image

Pixabay's terms forbid hotlinking its CDN from a sent email, so a Pixabay picture has to be copied onto your side before it can go in a template. Import downloads it and stores it as a normal image owned by the session's end user.

POST /public/plugin/v1/stock/import
{ "provider": "pixabay", "url": "https://pixabay.com/get/g8f2….jpg" }
FieldRequiredNotes
provideryesIn practice only pixabay. Unsplash and Pexels images are used by URL and are refused here
urlyesThe url from the image object. Max 2048 characters, and the host must be pixabay.com or cdn.pixabay.com

201

{
  "message": "Stock image imported successfully",
  "result": {
    "imported_image": { "uuid": "9f1c…", "path": "https://cdn.customer.com/9/9f1c….jpg", "…": "…" }
  }
}

Put imported_image.path in the template. The file lands in your bucket if one is attached, otherwise on MailEditor storage, where it counts against the plan's image_storage quota like any upload. It also shows up in the user's image library and can be deleted from there.

Statusresult.errorMeaning
422invalid_stock_urlNot a Pixabay host, or a provider that imports nothing. Unsplash and Pexels images belong in the template by URL
409storage_not_publicCustom storage has no public_url. Set it on the Custom Storage tab
402quota_exceededThe image_storage allowance is spent
502stock_import_failedThe download failed, or the file was empty or over 10 MB
429Upload rate limit

On this page