> ## Documentation Index
> Fetch the complete documentation index at: https://docs.corsair.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# ShortPixel API reference

> API reference for the ShortPixel plugin in Corsair: every `shortpixel.api.*` operation with its input and output types, taken from the plugin's Zod schemas.

> [!NOTE]
>
> **New to Corsair?** See [API access](https://docs.corsair.dev/concepts/api.md), [authentication](https://docs.corsair.dev/concepts/auth.md), and [error handling](https://docs.corsair.dev/concepts/error-handling).

## Account

### status

`account.status`

Read the API key's credits: monthly and one-time quota, calls used, captions quota, plan. Pass siteUrl to also check that ShortPixel can reach that site.

**Risk:** `read`

```ts theme={null}
await corsair.shortpixel.api.account.status({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `siteUrl` | `string` | No | Also check that ShortPixel can reach this site, e.g. [https://example.com](https://example.com) (answers DomainCheck). |

POST /v2/api-status.php. Plan, quota and credits used. siteUrl asks ShortPixel whether it can reach a site (DomainCheck).

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `Status` | `object \| null` | No | — |
| `APICallsMade` | `number \| string \| null` | No | — |
| `APICallsFree` | `number \| string \| null` | No | — |
| `APICallsQuota` | `number \| string \| null` | No | — |
| `APICallsQuotaOneTime` | `number \| string \| null` | No | — |
| `APICallsMadeOneTime` | `number \| string \| null` | No | — |
| `CaptionsCallsQuota` | `number \| string \| null` | No | — |
| `CaptionsCallsMade` | `number \| string \| null` | No | — |
| `CaptionsCallsRemaining` | `number \| string \| null` | No | — |
| `DateSubscription` | `string \| null` | No | — |
| `DomainCheck` | `string \| null` | No | — |
| `Unlimited` | `boolean \| string \| null` | No | — |
| `PlanType` | `string \| null` | No | — |
| `PlanCode` | `string \| null` | No | — |

> [accordion] Status full type
>
> ```ts theme={null}
> {
>   Code: number | string,
>   Message?: string | null
> } | null
> ```

***

## Domains

### add

`domains.add`

Add a domain to the ShortPixel CDN and associate it with this key. Safe to repeat; a domain another account owns is refused.

**Risk:** `write`

```ts theme={null}
await corsair.shortpixel.api.domains.add({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `domain` | `string` | Yes | Domain, e.g. example.com ([www.example.com](http://www.example.com) is a separate domain). |

Associates a domain with this account so its CDN traffic uses the account's credits.

**Output:** `object \| any[]`

> [accordion] Output full type
>
> ```ts theme={null}
> {
> } | any[]
> ```

***

### purgeCdn

`domains.purgeCdn`

Purge every file of a domain owned by this key from the CDN cache and from ShortPixel storage. example.com and [www.example.com](http://www.example.com) are purged separately.

**Risk:** `destructive`

```ts theme={null}
await corsair.shortpixel.api.domains.purgeCdn({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `domain` | `string` | Yes | Domain, e.g. example.com ([www.example.com](http://www.example.com) is a separate domain). |

Clears the CDN cache for the domain.

**Output:** `object \| any[]`

> [accordion] Output full type
>
> ```ts theme={null}
> {
> } | any[]
> ```

***

### purgeStorage

`domains.purgeStorage`

Delete every file ShortPixel stores for a domain owned by this key. example.com and [www.example.com](http://www.example.com) are purged separately.

**Risk:** `destructive`

```ts theme={null}
await corsair.shortpixel.api.domains.purgeStorage({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `domain` | `string` | Yes | Domain, e.g. example.com ([www.example.com](http://www.example.com) is a separate domain). |

Deletes every optimized copy ShortPixel stores for the domain.

**Output:** `object \| any[]`

> [accordion] Output full type
>
> ```ts theme={null}
> {
> } | any[]
> ```

***

### read

`domains.read`

Read the CDN status of a domain: 2 OK, 1 credits almost used up, -1 used up, -2 used up a while ago, -3 unreachable, plus quota and whether an account owns it. Needs no key.

**Risk:** `read`

```ts theme={null}
await corsair.shortpixel.api.domains.read({ domain: 'example.com' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `domain` | `string` | Yes | Domain, e.g. example.com ([www.example.com](http://www.example.com) is a separate domain). |

GET no-cdn.shortpixel.ai/read-domain/\{domain}. Needs no key. Status 2 OK, 1 almost out of credits, -1/-2 out of credits, -3 unreachable.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `Status` | `number \| string \| null` | No | — |
| `Domain` | `string \| null` | No | — |
| `HasAccount` | `boolean \| null` | No | — |
| `Unlimited` | `boolean \| string \| null` | No | — |
| `Email` | `string \| null` | No | — |
| `FreeCredits` | `number \| string \| null` | No | — |
| `UsedFreeCredits` | `number \| string \| null` | No | — |
| `CDNQuota` | `number \| string \| null` | No | — |
| `UsedCDN` | `number \| string \| null` | No | — |
| `TemporaryRedirectOrigin` | `boolean \| null` | No | — |

***

### revoke

`domains.revoke`

Remove this key's association with a CDN domain. Only the owner's key can do it.

**Risk:** `destructive`

```ts theme={null}
await corsair.shortpixel.api.domains.revoke({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `domain` | `string` | Yes | Domain, e.g. example.com ([www.example.com](http://www.example.com) is a separate domain). |

Removes that association.

**Output:** `object \| any[]`

> [accordion] Output full type
>
> ```ts theme={null}
> {
> } | any[]
> ```

***

### set

`domains.set`

Associate an existing CDN domain that has no owner with this key. Does not create the domain.

**Risk:** `write`

```ts theme={null}
await corsair.shortpixel.api.domains.set({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `domain` | `string` | Yes | Domain, e.g. example.com ([www.example.com](http://www.example.com) is a separate domain). |

**Output:** `object \| any[]`

> [accordion] Output full type
>
> ```ts theme={null}
> {
> } | any[]
> ```

***

### usage

`domains.usage`

Read CDN traffic and credits used per day for a domain owned by this key, with the account's quotas.

**Risk:** `read`

```ts theme={null}
await corsair.shortpixel.api.domains.usage({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `domain` | `string` | Yes | Domain, e.g. example.com ([www.example.com](http://www.example.com) is a separate domain). |

CDN traffic and credits used by the domain, with daily breakdowns (UsedCDN and UsedCredits are \[] or false when there is no usage yet).

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `Email` | `string \| null` | No | — |
| `APIQuota` | `number \| string \| null` | No | — |
| `APIQuotaOneTime` | `number \| string \| null` | No | — |
| `DaysToReset` | `number \| string \| null` | No | — |
| `IsSubaccount` | `number \| string \| null` | No | — |
| `IsAlias` | `number \| string \| null` | No | — |
| `RemainingCDNTraffic` | `number \| string \| null` | No | — |
| `UsedCDNTraffic` | `number \| string \| null` | No | — |
| `FreeAPICalls` | `number \| string \| null` | No | — |
| `PaidAPICalls` | `number \| string \| null` | No | — |
| `PaidAPICallsOneTime` | `number \| string \| null` | No | — |
| `CDNQuota` | `number \| string \| null` | No | — |
| `Unlimited` | `boolean \| string \| null` | No | — |
| `UsedCDN` | `any` | No | — |
| `UsedCredits` | `any` | No | — |

***

## Images

### adaptive

`images.adaptive`

Fetch an image through the Adaptive Images CDN with the given resize, crop, quality and format settings, and return it base64 with its size and type. Uses the domain's CDN traffic and credits.

**Risk:** `read`

```ts theme={null}
await corsair.shortpixel.api.images.adaptive({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `imageUrl` | `string` | Yes | Absolute URL of the image (or CSS/JS file). |
| `width` | `number` | No | — |
| `height` | `number` | No | — |
| `crop` | `top \| right \| bottom \| left \| center` | No | Crop side when width and height are both set; default smart. |
| `specialCrop` | `string` | No | Offset:size\[:resize], e.g. 700x1000:2400x1000:480x200. |
| `quality` | `lossy \| glossy \| lossless \| lqip` | No | — |
| `to` | `webp \| avif \| auto` | No | Next-gen format when the browser accepts it. |
| `keepExif` | `boolean` | No | — |
| `ret` | `wait \| img \| blank` | No | While processing: wait, redirect to the original, or blank. |
| `client` | `string` | No | Cache key segment (default "client"). |
| `cdn` | `boolean` | No | true (default) uses cdn.shortpixel.ai; false uses no-cdn.shortpixel.ai. |
| `includeData` | `boolean` | No | Return the image as base64 (default true). |

Fetches that link and returns the optimized file. The first fetch of an image can return the original while ShortPixel optimizes it.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `url` | `string` | No | — |
| `contentType` | `string \| null` | Yes | — |
| `byteLength` | `number` | Yes | — |
| `contentBase64` | `string` | No | — |

***

### adaptiveUrl

`images.adaptiveUrl`

Build an Adaptive Images CDN URL that resizes, crops, compresses and converts an image on the fly. Makes no request; the image domain must be associated with the account (domains.add).

**Risk:** `read`

```ts theme={null}
await corsair.shortpixel.api.images.adaptiveUrl({ imageUrl: 'https://example.com/a.jpg', width: 300, quality: 'lossy', to: 'webp' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `imageUrl` | `string` | Yes | Absolute URL of the image (or CSS/JS file). |
| `width` | `number` | No | — |
| `height` | `number` | No | — |
| `crop` | `top \| right \| bottom \| left \| center` | No | Crop side when width and height are both set; default smart. |
| `specialCrop` | `string` | No | Offset:size\[:resize], e.g. 700x1000:2400x1000:480x200. |
| `quality` | `lossy \| glossy \| lossless \| lqip` | No | — |
| `to` | `webp \| avif \| auto` | No | Next-gen format when the browser accepts it. |
| `keepExif` | `boolean` | No | — |
| `ret` | `wait \| img \| blank` | No | While processing: wait, redirect to the original, or blank. |
| `client` | `string` | No | Cache key segment (default "client"). |
| `cdn` | `boolean` | No | true (default) uses cdn.shortpixel.ai; false uses no-cdn.shortpixel.ai. |

Builds a [https://cdn.shortpixel.ai/\&lt;client\&gt;/\&lt;settings\&gt;/\&lt;image](https://cdn.shortpixel.ai/\&lt;client\&gt;/\&lt;settings\&gt;/\&lt;image) URL> link. Makes no request and costs nothing until someone opens the link.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `url` | `string` | Yes | — |

***

### checkUpload

`images.checkUpload`

Check uploaded files that were still processing, by the OriginalURL images.upload returned. Only checks the status; pass the same settings as the upload.

**Risk:** `read`

```ts theme={null}
await corsair.shortpixel.api.images.checkUpload({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `lossy` | `0 \| 1 \| 2` | No | 1 lossy (default), 2 glossy, 0 lossless. |
| `wait` | `number` | No | Seconds (0-30) to wait for the result before answering. Code 1 means still processing: call again with the same URL. |
| `upscale` | `0 \| 2 \| 3 \| 4` | No | AI upscale factor: 2, 3 or 4; 0 for none. |
| `resize` | `0 \| 1 \| 3 \| 4` | No | 0 none, 1 outer (cover the box), 3 inner (fit in the box), 4 AI smart crop. |
| `resizeWidth` | `number` | No | — |
| `resizeHeight` | `number` | No | — |
| `cmyk2rgb` | `boolean` | No | Convert CMYK to RGB (default on). |
| `keepExif` | `boolean` | No | Keep EXIF data (default off). |
| `convertto` | `string` | No | Extra formats: "+webp", "+avif", "+webp\|+avif" (also optimize the original) or "webp", "avif", "jpg", "png", "gif". |
| `bgRemove` | `string` | No | AI background removal: "1" transparent, "#rrggbb" or "#rrggbbxx" color, or a background image URL. |
| `bgRemoveFormat` | `orig \| auto` | No | auto switches to PNG when the result needs transparency. |
| `refresh` | `boolean` | No | Fetch the image again and re-optimize instead of reusing a result. |
| `fileUrls` | `string[]` | Yes | OriginalURL values from an earlier images.upload answer that was still processing (code 1). |

POST /v2/post-reducer.php with file\_urls (the OriginalURL values images.upload returned). Does not upload anything again.

**Output:** `unknown`

***

### cleanup

`images.cleanup`

Drop optimized results for up to 100 image URLs from ShortPixel, so the next optimize of the same URL starts fresh. The download URLs stop working.

**Risk:** `destructive`

```ts theme={null}
await corsair.shortpixel.api.images.cleanup({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `urls` | `string[]` | Yes | — |

POST /v2/cleanup.php. Deletes ShortPixel's stored optimized copies of the URLs, so the next optimize runs again and costs again.

**Output:** `object \| any[]`

> [accordion] Output full type
>
> ```ts theme={null}
> {
> } | any[]
> ```

***

### optimize

`images.optimize`

Optimize up to 100 public image or PDF URLs (Reducer API): lossy, glossy or lossless, resize or AI smart crop, AI upscale, AI background removal, WebP/AVIF conversion. Spends one credit per image that shrinks by more than 5%; each extra WebP/AVIF copy (convertto +webp/+avif) and the AI options (upscale, background removal) use more credits. Status.Code 1 means still processing: call again with the same URLs; 2 means done, with download URLs and sizes.

**Risk:** `destructive`

```ts theme={null}
await corsair.shortpixel.api.images.optimize({ urls: ['https://shortpixel.com/img/tests/beautiful-woman.jpg'], lossy: 1, wait: 20, convertto: '+webp' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `lossy` | `0 \| 1 \| 2` | No | 1 lossy (default), 2 glossy, 0 lossless. |
| `wait` | `number` | No | Seconds (0-30) to wait for the result before answering. Code 1 means still processing: call again with the same URL. |
| `upscale` | `0 \| 2 \| 3 \| 4` | No | AI upscale factor: 2, 3 or 4; 0 for none. |
| `resize` | `0 \| 1 \| 3 \| 4` | No | 0 none, 1 outer (cover the box), 3 inner (fit in the box), 4 AI smart crop. |
| `resizeWidth` | `number` | No | — |
| `resizeHeight` | `number` | No | — |
| `cmyk2rgb` | `boolean` | No | Convert CMYK to RGB (default on). |
| `keepExif` | `boolean` | No | Keep EXIF data (default off). |
| `convertto` | `string` | No | Extra formats: "+webp", "+avif", "+webp\|+avif" (also optimize the original) or "webp", "avif", "jpg", "png", "gif". |
| `bgRemove` | `string` | No | AI background removal: "1" transparent, "#rrggbb" or "#rrggbbxx" color, or a background image URL. |
| `bgRemoveFormat` | `orig \| auto` | No | auto switches to PNG when the result needs transparency. |
| `refresh` | `boolean` | No | Fetch the image again and re-optimize instead of reusing a result. |
| `urls` | `string[]` | Yes | Public image (or PDF) URLs, at most 100. |
| `paramList` | `object[]` | No | Per-URL settings, same length and order as urls. |
| `returnData` | `any[]` | No | Any list; ShortPixel returns it unchanged. |

POST /v2/reducer.php with urllist (up to 100 URLs). wait (0-30 s) sets how long ShortPixel waits before answering; Status.Code 1 means still processing, so call again with the same URLs until it is 2. Download URLs in the result expire after about an hour.

> [accordion] paramList full type
>
> ```ts theme={null}
> {
>   lossy?: 0 | 1 | 2,
>   wait?: number,
>   upscale?: 0 | 2 | 3 | 4,
>   resize?: 0 | 1 | 3 | 4,
>   resizeWidth?: number,
>   resizeHeight?: number,
>   cmyk2rgb?: boolean,
>   keepExif?: boolean,
>   convertto?: string,
>   bgRemove?: string,
>   bgRemoveFormat?: orig | auto,
>   refresh?: boolean
> }[]
> ```

**Output:** `unknown`

***

### optimizeSync

`images.optimizeSync`

Optimize one public image URL and return the optimized file itself, base64 (reducer-sync). Same settings and credit cost as images.optimize.

**Risk:** `destructive`

```ts theme={null}
await corsair.shortpixel.api.images.optimizeSync({ url: 'https://shortpixel.com/img/tests/beautiful-woman.jpg', resize: 1, resizeWidth: 400, resizeHeight: 400 });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `lossy` | `0 \| 1 \| 2` | No | 1 lossy (default), 2 glossy, 0 lossless. |
| `wait` | `number` | No | Seconds (0-30) to wait for the result before answering. Code 1 means still processing: call again with the same URL. |
| `upscale` | `0 \| 2 \| 3 \| 4` | No | AI upscale factor: 2, 3 or 4; 0 for none. |
| `resize` | `0 \| 1 \| 3 \| 4` | No | 0 none, 1 outer (cover the box), 3 inner (fit in the box), 4 AI smart crop. |
| `resizeWidth` | `number` | No | — |
| `resizeHeight` | `number` | No | — |
| `cmyk2rgb` | `boolean` | No | Convert CMYK to RGB (default on). |
| `keepExif` | `boolean` | No | Keep EXIF data (default off). |
| `convertto` | `string` | No | Extra formats: "+webp", "+avif", "+webp\|+avif" (also optimize the original) or "webp", "avif", "jpg", "png", "gif". |
| `bgRemove` | `string` | No | AI background removal: "1" transparent, "#rrggbb" or "#rrggbbxx" color, or a background image URL. |
| `bgRemoveFormat` | `orig \| auto` | No | auto switches to PNG when the result needs transparency. |
| `refresh` | `boolean` | No | Fetch the image again and re-optimize instead of reusing a result. |
| `url` | `string` | Yes | Public image URL. |
| `includeData` | `boolean` | No | Return the image as base64 (default true). |

POST /v2/reducer-sync.php. Waits for one image and returns the optimized file itself (base64), not URLs. includeData false returns only the type and size.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `url` | `string` | No | — |
| `contentType` | `string \| null` | Yes | — |
| `byteLength` | `number` | Yes | — |
| `contentBase64` | `string` | No | — |

***

### status

`images.status`

Check whether ShortPixel has a result for an image URL sent to images.optimize (code 0 Not found when it has none).

**Risk:** `read`

```ts theme={null}
await corsair.shortpixel.api.images.status({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `url` | `string` | Yes | An image URL sent to images.optimize. |

POST /v2/image-status.php. Code 0 means ShortPixel has no record of the URL, 2 means it is optimized.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `Status` | `object \| null` | No | — |

> [accordion] Status full type
>
> ```ts theme={null}
> {
>   Code: number | string,
>   Message?: string | null
> } | null
> ```

***

### upload

`images.upload`

Upload up to 10 image files (base64) and optimize them (Post-Reducer API). Same settings and credit cost as images.optimize. A file still processing (code 1) returns a temporary OriginalURL: poll it with images.checkUpload instead of uploading again.

**Risk:** `destructive`

```ts theme={null}
await corsair.shortpixel.api.images.upload({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `lossy` | `0 \| 1 \| 2` | No | 1 lossy (default), 2 glossy, 0 lossless. |
| `wait` | `number` | No | Seconds (0-30) to wait for the result before answering. Code 1 means still processing: call again with the same URL. |
| `upscale` | `0 \| 2 \| 3 \| 4` | No | AI upscale factor: 2, 3 or 4; 0 for none. |
| `resize` | `0 \| 1 \| 3 \| 4` | No | 0 none, 1 outer (cover the box), 3 inner (fit in the box), 4 AI smart crop. |
| `resizeWidth` | `number` | No | — |
| `resizeHeight` | `number` | No | — |
| `cmyk2rgb` | `boolean` | No | Convert CMYK to RGB (default on). |
| `keepExif` | `boolean` | No | Keep EXIF data (default off). |
| `convertto` | `string` | No | Extra formats: "+webp", "+avif", "+webp\|+avif" (also optimize the original) or "webp", "avif", "jpg", "png", "gif". |
| `bgRemove` | `string` | No | AI background removal: "1" transparent, "#rrggbb" or "#rrggbbxx" color, or a background image URL. |
| `bgRemoveFormat` | `orig \| auto` | No | auto switches to PNG when the result needs transparency. |
| `refresh` | `boolean` | No | Fetch the image again and re-optimize instead of reusing a result. |
| `files` | `object[]` | Yes | — |

POST /v2/post-reducer.php as multipart, up to 10 files given as base64. The answer's OriginalURL is a temporary copy; poll it with images.checkUpload.

> [accordion] files full type
>
> ```ts theme={null}
> {
>   filename: string,
>   contentBase64: string,
>   path?: string
> }[]
> ```

**Output:** `unknown`

***


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.